Interpreting DXF BLOCK and INSERT

Steve Biederman

Usenet Archive
Joined
Sep 12, 2003
Messages
2
Reaction score
0
Hi. I'm not an AutoCAD expert but am trying to write a DXF reader.

I'm having trouble interpreting the information in DXF's BLOCK and INSERT.

What's the algorithm for taking the location in a BLOCK, the Xscale factor, the Yscale factor, the rotation, the INSERT point, and determining where something goes? Let's assume we're in 2D, no Z values need to be considered.

Here's a concrete example:

The BLOCK has a line from, say, (3, 5) to (7, 13).
The INSERT says to Xscale by -1.5, to Yscale by 1.5, to rotate 270 degrees, and to insert at (15, 17). Where should this line end up?

Thanks
 
Let me follow up by describing what my code is doing now.

This code gets the right answer almost all the time,

but there must be something wrong, because I have one

test case on which it draws the result in the wrong place.

 

What's wrong?

 

   do_one_insert {

      X = the insert's X - the block's X basepoint

      Y = the insert's Y - the block's Y basepoint

 

      if (the insert's X scale < 0 and the insert's Y scale > 0)

         add 180 degrees to the insert's rotation

 

      Take all the points from the entities in the block and

      rotate them "rotation" amount

 

      Take all the points from the entities in the block and

      multiply them by X scale for all the X coordinates or by

      Y scale for all the Y coordinates and then

      add X or Y as appropriate

   }

 

-----Original Message-----

Sent: Friday, September 12, 2003 4:23 PM

Subject: Interpreting DXF BLOCK and INSERT

 

Hi. I'm not an AutoCAD expert but am trying to write a DXF reader.

I'm having trouble interpreting the information in DXF's BLOCK and INSERT.

What's the algorithm for taking the location in a BLOCK, the Xscale factor,

the Yscale factor, the rotation, the INSERT point, and determining where

something

goes? Let's assume we're in 2D, no Z values need to be considered.

Here's a concrete example:

The BLOCK has a line from, say, (3, 5) to (7, 13).

The INSERT says to Xscale by -1.5, to Yscale by 1.5, to rotate 270 degrees,

and

to insert at (15, 17). Where should this line end up?

Thanks
 
Steve,

You should use a transformation matrix. There is plenty of info in this ng, and on the web regarding these.

--
R. Robert Bell, MCSE
www.AcadX.com

| Let me follow up by describing what my code is doing now. | This code gets the right answer almost all the time, | but there must be something wrong, because I have one | test case on which it draws the result in the wrong place. | | What's wrong? | | do_one_insert { | X = the insert's X - the block's X basepoint | Y = the insert's Y - the block's Y basepoint | | if (the insert's X scale < 0 and the insert's Y scale > 0) | add 180 degrees to the insert's rotation | | Take all the points from the entities in the block and | rotate them "rotation" amount | | Take all the points from the entities in the block and | multiply them by X scale for all the X coordinates or by | Y scale for all the Y coordinates and then | add X or Y as appropriate | } | | -----Original Message----- | From: Biederman, Steve | Sent: Friday, September 12, 2003 4:23 PM | To: Biederman, Steve | Subject: Interpreting DXF BLOCK and INSERT | | Hi. I'm not an AutoCAD expert but am trying to write a DXF reader. | I'm having trouble interpreting the information in DXF's BLOCK and INSERT. | What's the algorithm for taking the location in a BLOCK, the Xscale factor, | the Yscale factor, the rotation, the INSERT point, and determining where | something | goes? Let's assume we're in 2D, no Z values need to be considered. | Here's a concrete example:
| The BLOCK has a line from, say, (3, 5) to (7, 13).
| The INSERT says to Xscale by -1.5, to Yscale by 1.5, to rotate 270 degrees, | and | to insert at (15, 17). Where should this line end up?
| Thanks
 

Latest threads

Back
Top