Units in a dxf file and dealing with blocks

Use this forum to ask questions about how to do things in dxflib.

Moderator: andrew

Post Reply
rich
Newbie Member
Posts: 3
Joined: Tue Mar 25, 2014 5:30 pm

Units in a dxf file and dealing with blocks

Post by rich » Tue Mar 25, 2014 6:18 pm

Hi all, I've recently started using dxflib and have had some success, but have also come across a couple of things I'm not sure how to proceed with.

1) I'm dealing with files that have different units (one in mm, one in m [for example]). Is there a function that detects this?

2a) Some lines are absent and some are clearly in the wrong place when I re plot them (in opengl) and I think this is to do with blocks. I see there is a block data type in the class reference and function calls at the start and end of a block, but there doesn't seem to be enough information about how to use them. Surely it would need orientation of the block, not just its xyz position? And there appears to be no documentation on how they are dealt with generally. Does dxflib define the definition of the blocks as it reads them then produce the equivalent lines/polylines etc? Or is that left to us?

2b) A related question to do with dealing with format: In one of my files polyline structures obviously had say n=4 vertices associated with it, but the member Dl_PolyLine::number was 0 each time (it worked properly for another file). I *think* I have a workaround (based on the assumption that vertex data is only ever in a polyline, but is this a bug?

3) Finally, this might be a relevant point. I'm using version 2.2.0.0.1 because it is the only download (I could find) that came with a ./configure script and a makefile. The version 3.3.4 on the ribbonsoft website doesn't have either of these things (only a Qt project file?) yet the developer instructions clearly refer to a configure script and make file.

Thanks!

Rich.

User avatar
andrew
Site Admin
Posts: 9037
Joined: Fri Mar 30, 2007 6:07 am

Re: Units in a dxf file and dealing with blocks

Post by andrew » Wed Mar 26, 2014 9:49 am

rich wrote:1) I'm dealing with files that have different units (one in mm, one in m [for example]). Is there a function that detects this?
setVariableInt is called with key: "INSUNITS".
Please refer to the DXF reference for possible values:
http://images.autodesk.com/adsk/files/a ... ce_enu.pdf
-> Header Section
-> $INSUNITS
rich wrote:2a) Some lines are absent and some are clearly in the wrong place when I re plot them (in opengl) and I think this is to do with blocks. I see there is a block data type in the class reference and function calls at the start and end of a block, but there doesn't seem to be enough information about how to use them. Surely it would need orientation of the block, not just its xyz position? And there appears to be no documentation on how they are dealt with generally. Does dxflib define the definition of the blocks as it reads them then produce the equivalent lines/polylines etc? Or is that left to us?
dxflib only parses the format. It does not interpret the data in any way.
A BLOCK (=block definition) has only a base point, no rotation angle, scale, etc. Base point is almost always 0/0/0.
A block is then inserted by entity type INSERT (=block reference).
2b) A related question to do with dealing with format: In one of my files polyline structures obviously had say n=4 vertices associated with it, but the member Dl_PolyLine::number was 0 each time (it worked properly for another file). I *think* I have a workaround (based on the assumption that vertex data is only ever in a polyline, but is this a bug?
Could you attach the file for testing? Thanks.
I would generally recommend to not use this value and simply parse all vertices that are stored. This information is redundant and would likely not be stored in a modern format anymore.
3) Finally, this might be a relevant point. I'm using version 2.2.0.0.1 because it is the only download (I could find) that came with a ./configure script and a makefile. The version 3.3.4 on the ribbonsoft website doesn't have either of these things (only a Qt project file?) yet the developer instructions clearly refer to a configure script and make file.
Yes, we don't use configure / make anymore here and don't have the resources to keep it up to date.
If you decide to create configure/make scripts for the latest version, feel free to post them there, so they can be included in future versions again.

rich
Newbie Member
Posts: 3
Joined: Tue Mar 25, 2014 5:30 pm

Re: Units in a dxf file and dealing with blocks

Post by rich » Wed Mar 26, 2014 3:10 pm

Thanks for your response. Some of it is working well, particularly the units issue (who knew you could deal in parsecs!). And yes I am ignoring Dl_PolyLine::number now.

My only questions remaining are things to do with how blocks are used. I'm aware dxflib only parses the information and we should consult the specifications, but I've looked through them and there are definite ambiguities/things they don't address.

For instance:

1) you can nest inserts within block definitions: what are the rules for nesting the transformations? They just don't say.

2) columns and rows of blocks in an insert: what is defined as the width of a column and the height of the row? Is this to be included in the row spacing and column spacing variables? Or is it the maximum width in x or y space and is this relative to the start position of the block or not? And are these transformations/calculations to be done before or after rotation? They just don't say, but all these things are certainly not commutative.

3) what axis and in with what convention does the rotation take place? Why is there only one angle seeing as one needs two angles to rotate something in 3D space? Again they just don't say.

And links to documentation which does go through these, or just any guidance, would be immensely helpful: the answers don't appear to be here : http://images.autodesk.com/adsk/files/acad_dxf0.pdf

Thanks again,

rich.

rich
Newbie Member
Posts: 3
Joined: Tue Mar 25, 2014 5:30 pm

Re: Units in a dxf file and dealing with blocks

Post by rich » Wed Mar 26, 2014 3:25 pm

And looking at the output I'm getting I have a strong suspicion that I have blocks which should have non zero bpx and bpy values but are being returned as 0 by the parser. That is because the line data in them is drawing metre long objects between distances like 44 and 45 m yet bpx and bpy are 0 and so when I plot them with the insert points from the insert data type they are (suprise surprise) about 44-45 metres too far along the axes. Is this a bug, or something about me using an old version? If so how do I update? I'm not using Qt. Can I just copy the new src over the old source and run the old configure and make files?

Thanks,

Rich.

Post Reply

Return to “dxflib 'How Do I' Questions”