[Drawkit] DKShapeGroups and DXF blocks

Allan Daly allandaly at me.com
Mon Apr 13 14:47:36 PDT 2009


Graham,

I'm getting ready to tackle drawing DXF "blocks" in DK and I wonder if  
I could ask you for some conceptual help.

A "block" is a collection of DXF entities with a unique name that can  
be placed in a drawing multiple times. Inside the block all of the  
entities are positioned with respect to a base point. The entire block  
can then be placed in a drawing by "inserting" it at a location. The  
base point of the block is placed at the "insertion" point. Block  
translations and rotations then are referenced to the insertion point.

The DKShapeGroup clearly is a close match to much of this behavior.

If I have a list of entities that need to go into the DKShapeGroup,  
what is the best way to create the group? Do I need to add them to a  
drawing on a layer, then group them all together? Or is there a way to  
add a new DKShape (or whatever) into an existing group one at a time?  
How do I get the DKShapes into the right position relative to the  
"base point?" How does DK handle the base point? The documentation of  
the DKShapeGroup methods suggests that the base point becomes the  
center of the bounding rectangle -- but I need to be able to set the  
basepoint to match the block definition (could be anywhere) so when I  
insert it into the drawing later it will be in the right place.

Also -- can I create a DKShapeGroup and not draw it? A block is really  
just a definition of a group of entities. It is not drawn until it is  
inserted into the drawing. Can I create a non-drawn DKShapeGroup then  
copy it when I need to insert it? is there an easy way to copy  
DKShapeGroups? Or even better, is there a way to reference the  
DKShapeGroup so that if I change the DKShapeGroup definition then all  
instances where that group is placed in the drawing would be  
automatically updated?

I'm sure I can dive into this and get something working -- but if you  
wouldn't mind giving me some high level advice as to how you think it  
might be best to proceed I think that would save me a lot of time.

Thanks for any help you can send my way.

-Allan


More information about the Drawkit mailing list