DXF(to find the absolute corrdinates of LINEs inside)

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

Moderator: andrew

Post Reply
wwinthan
Junior Member
Posts: 16
Joined: Thu Aug 14, 2008 4:59 pm

DXF(to find the absolute corrdinates of LINEs inside)

Post by wwinthan » Thu Aug 14, 2008 5:37 pm

I have a software that needs to process dxf files and I am having a
nightmare trying to find the absolute corrdinates of LINEs inside
blocks.

This is what I know about BLOCKS:

Each BLOCK (in the BLOCKS section) has a block name that is related to
an INSERT entity (In the ENTITIES section).
The INSERT entity defines the transformation parameters such as origin,
scale and rotation, to transform the BLOCK coordinates from relative to
absolute coordinates.
All coordinates in the BLOCK may be transformed using the parameters
defined in INSERT.
Each BLOCK ends with ENDBLK.

This is what I need to do:

I need to transform the relative coordinates of LINEs inside blocks (in
the BLOCKS section) to absolute coordinates.
What I do is search (using the block name) the corresponding INSERT
entity (in the ENTITIES section) which gives me the coordinates of the
block, so by adding the relative + block corrdinates I can obtain the
absolute coordinates for LINEs.

SO FAR THE EXPLANATION, NOW THE PROBLEM TO SOLVE:

What can I do if I find more than one INSERT entity with the same block
name ?
How do I know which one applies to each LINE, since for a given block
name there is only one BLOCK structure in the blocks SECTION but in
some cases there is more than one INSERT entity in the ENTITIES
section


I tried following but doesn't work. the following are dxf file opened in notepad.
/////////////////////////
//////////////////////////

BLOCKBLOCKBLOCKBLOCKBLOCK
5
62
330
4A
100
AcDbEntity
8
0
100
AcDbBlockBegin
2
CK_HATCH_0319
70
0
71
0
10 <<base point of block(x)
0.0
20 <<base point of block(y)
0.0
30
0.0
3
CK_HATCH_0319
1

0
LINE
5
4B
330
4A
100
AcDbEntity
8
Unnamed [40]
6
Continuous
62
4
48
2.0
370
0
100
AcDbLine
10
-0.5967346429824829 <<line (relative coordinate in block: x1)
20
-2.942419290542603 <<line (relative coordinate in block: y1)
30
0.0
11
-0.4835976660251617 <<line (relative coordinate in block: x2)
21
-2.942419290542603 <<line (relative coordinate in block: y2)
31
0.0
/////////////////////////////////////////
INSERT INSERT INSERT INSERT
/////////////////////////////////////////
INSERT INSERT INSERT INSERT

5
476
330
471
100
AcDbEntity
8
Unnamed [20]
62
2
370
-2
100
AcDbBlockReference
2
_CLOSED
10
-4.805948448181153 << Insert x value
20
-0.1038970574736592 <<Insert y value(related to block_
30
0.0
41
0.125 <<Insert x scale factor
42
0.125 <<Insert y scale factor
43
0.125
////////////////////////////////////////////////////////////
Here goes question
-------------------------
Your solution doesn't work!!!!!!!!!
Those co-ordinates are block base point. Block entites will be first translated using the base point first. Thus line would be drawn at:
line (relative coordinate in block: x1) = Insert x+ (line {relative coordinate in block: x1}-basepoint{block}) * Insert x scale factor
line (relative coordinate in block: x2) = Insert y+ (line {relative coordinate in block: y1}-basepoint{block}) * Insert y scale factor

------------------------------------------------------------------------------

wwinthan
Junior Member
Posts: 16
Joined: Thu Aug 14, 2008 4:59 pm

Post by wwinthan » Thu Aug 14, 2008 10:31 pm

the above formaul does work out for m_text and m_Mtext but it doesn't work out for lines and polyines,etc.
is it because there is attributes which i need to use along with Insert? what information i need to extract from attributes to use with Insert? I'm not quite getting ur point..could you plz give an example on that. Also how do you know from my example that there is no attributes come with Insert? how do you notice that?
also i saw rotation as a member of Insert. I don't know what is the use of rotation and how to use it? could you plz give an example on it also?
for the last question, in dxf they use differnt font which is different from "Arial, Times new roman,etc" . so when i'm trying to read dxf and write to dwf, the font is not right. how do i relate dxf font with our windows fonts? and how to extract font info from dxf?
thanks again for ur reply and hope to hear back soon from you
sorry for wasting ur time. and thanks again
PS: it'll be great if u would like to email me ur email address only if i'ts not troubling u and it 'll be convenient for me to get reply back from you.
thanks
winthan
thanks

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

Post by andrew » Fri Aug 15, 2008 7:43 am

Please note that dxflib is a format parser only. It does not interpret the information in the DXF file in any way. dxflib parses DXF files and hands the information to you.

For documentation about the DXF format, please refer to the DXF specification at:
http://www.autodesk.com/techpubs/autocad/acad2000/dxf/

Or search the Internet for "DXF specification".

Post Reply

Return to “dxflib 'How Do I' Questions”