This project has moved and is read-only. For the latest updates, please go here.

Determining the ortographic view

Nov 16, 2012 at 9:11 AM

Hi,

In the AutoCAD software there are 3D views (Top, Bottom, Front, Left, Right, and Back).
When you draw dimensions for the particular 3D view, they are only visible when this 3D view is active.
In other words, when the 'Left' view is shown, there are only displayed dimensions belonging to the Left view, not those belonging to the Front view, Top view etc.

This information must be somehow stored in a dxf file. I wonder if there is a way to read that information using netDxf.

Note: I spent time by reading on dxf WCS, OCS, UCS and analysing dxf files to find out that dimension sub-entities have 30 and 31 (Z start/end) always 0.0. )-:

Thanks a lot,
Adam

Nov 16, 2012 at 12:52 PM

Let’s see.

The views don’t have anything to do in the way entities are drawn or build; it is just a way to see the world. I don’t understand your problem with this, the entities doesn’t belong to any view in particular; perhaps your problem lies with the visualization options.

It is the UCS (User Coordinate System) what matters; by default it is the World Coordinate System (a plane which normal is (0, 0, 1) and the origin is at (0, 0, 0)). In AutoCAD you can define any other coordinate system so any new object will be build according with this UCS, but this is just a way to help with the drawing process.

But all of this doesn’t even apply on how the coordinates are written in a dxf. They are always written in WCS or, sometimes, in OCS (Object Coordinate System). If you take, for example, a point the location will be defined in WCS; it doesn’t matter if it was created originally in a UCS. However, there are entities that require information give in OCS; this means that those coordinates are given in accordance with the object coordinates system which they belong. In the dxf documentation you can find the formula AutoCAD uses to create this OCS, read the section Object Coordinate Systems under the Advanced DXF Issues chapter.

So, with your example with the dimension the code 30 means that the Z coordinate is 0.0 in WCS and code 31 is the Z coordinate in OCS, the reference object is the dimension. If you need all your coordinates in WCS you will have to build first the transformation matrix (check the docs) to convert OCS points to WCS point, or vice versa.

Daniel

Nov 26, 2012 at 2:24 PM

Many thanks. I read the Autocad dxf documentation, googled a lot, but no progress so far. )-:
Thinking in 3D has never been my cup of tea. Unfortunately, as I'm working for a construction company now, it is the part of the software I'm developing.

To sum up: Let's have a cuboid (block). In AC2000LT:

  • Views->3D views->Top ; Dimension->Linear (will be visible just in this view and in a Bottom view with a mirrored text)
  • Views->3D views->Front ; Dimension->Linear (will be visible just in this view and in a Back view with a mirrored text)
  • Views->3D views->Left ; Dimension->Linear (will be visible just in this view and in a Right view with a mirrored text)
  • Save as AC2000 dxf file

 

When opened using netdxf-81260, I can see in the object structure of the DxfDocument:

  • dimensions, count = 3, null (as I understand you are just implementing this...)
  • blocks: (*Model_space, *Paper_space, <block of the cuboid>, *D1, *D2, *D3)

In each *Dn block:

  • BasePoint is always {0;0;0}
  • There are 9 entities (3 Line, 2 Solid, 1 MText, 3 Point).
  • each Line has StartPoint, EndPoint Z-values = 0; Normal = {0;0;1}
  • each Solid has Z-value for each vertex = 0; Normal = {0;0;1}
  • first two Points have non-zero Z-value (the clue here?); Normal = {0;0;1}

I found just 2008 and 2004 dxf specification. There is something on dimension's "Attachment point", but I have no idea how could it be used.

I've no idea how to build the transformation matrix, as in the *Dn block there are no clues(?) what its OCS is.

What I need is just display the dimensions in a free 3D view correctly, or at least to find out whether to draw a dimension in a particular orthographic view or not.

I wonder if the implementation of the Dimension object (at DxfDocument level) will bring some light into it. In such case, I'm keeping my fingers crossed for it.

Cheers, Adam

Nov 28, 2012 at 8:01 AM

OK, I reconsidered the idea of drawing dimensions directly into a free 3D view controlled by an arcball as there were too many problems (e.g. when the dimensions should be visible etc.) and I just draw them into 2D orthographic views, hence I don't need those OCS to WCF transfomations for dimensions.

As for me, this post could be closed.

Thanks anyway, Adam

Nov 28, 2012 at 3:14 PM
Edited Nov 29, 2012 at 3:40 AM

The relationship between a dimension and its block, it is the same as the relationship between an insert entity and the block that it references. So the orientation that you need to look for it is not in the block definition but in the entity that makes use of it.

 

Every dimension entity holds in the 210, 220, and 230 codes the normal vector. Therefore all the entities in the block will have to be transformed with that normal. You can find my implementation of the AutoCAD Arbitrary Axis Algorithm in the MathHelper class.

 

You can find the official dxf documentation published by Autodesk in http://usa.autodesk.com/adsk/servlet/item?siteID=123112&id=12272454&linkID=10809853,  the pdfs there have a chapter call Advanced DXF Issues, there you will find extended information on object coordinate systems and the arbitrary axis algorithm.

 

If you are working for a construction company it is very probable that all the drawing that you are dealing with are just 2d drawing plans, and if nobody wants to mess it up, they are drawn in wold coordinates. I am an architect and besides building 3d models for rendering the rest of the plans I have done are just 2d drawings.

 

So any entity drawn in WCS will have as normal the (0,0,1) vector, therefore if you build the rotation matrix with that vector you will get the Identity matrix, so no transformation is really needed.

 

Imagine yourself seeing a drawing on a piece of paper, imagine that the sides of the paper are the X and Y axis and the vertical the Z, and a corner the origin. The elements of the drawing can be referenced to this coordinate system by its x, y, and z components; this is the information you read from the dxf, some coordinates might need previous transformations if they are defined in OCS. Once everything is in place, it is the moment to decide from where you are looking at the scene. Both the eye and the target will have its coordinates defined in the same system as the rest of the elements of the drawing. A top view will have for example the eye at (0,0,1) and the target as (0,0,0). A side view can be (1,0,0) for the eye and (0,0,0) for the target; but from this view you will not see anything since we are dealing with flat objects.

 

Giving the possibility to free move a camera around a flat world it is not very useful, just zoom and translation should be enough.

 

Daniel