[Drawkit] DKShapeGroup bump in the road
Allan Daly
allandaly at me.com
Thu Apr 16 22:26:20 PDT 2009
Ah ha. Thanks.
In the AutoCAD/DXF world, blocks play two roles. 1) They allow shapes
to be grouped together as your DKShapeGroup does. 2) They allow for
the creation of a one to many relationship that allows for a block
object to be defined once and inserted many times. Any changes to the
original object are automatically updated across all the insertions.
So the logic of having at least 2 objects in a group makes sense in
the DXF world for purpose #1, but not purpose #2. Yes, a DXF block can
contain only one entity.
Since there is no way in DK to reproduce the one-to-many link that DXF
blocks allow I don't have to worry about that path. I guess I have two
options. I could either check to see if a block has only one entity
and if it does I can not bother with creating a group. Or, I can
modify your framework as you suggested below.
I would rather not have to manage my own custom version of your
framework so I'll do the one entity check.
Thanks again.
-Allan
On Apr 16, 2009, at 10:13 PM, Graham Cox wrote:
>
> On 17/04/2009, at 3:04 PM, Allan Daly wrote:
>
>> I cannot figure out why does this code not properly create a new
>> DKShapeGroup containing 1 object.
>>
>> Any thoughts?
>>
>
>
> Yep. Because a group must have at least 2 objects. This line in -
> setGroupObjects: (204 in my copy) rejects < 2:
>
> if([groupObjects count] < 2 )
> return;
>
>
> This then causes the initialiser of DKShapeGroup to gracefully fail
> and return nil.
>
> Now, it isn't absolutely essential that a group have > 1 object, it
> just didn't seem to make sense that such a thing should exist.
> However, if it's allowed by the DXF format, then you should find
> that simply removing that check should allow it to work. Otherwise,
> try adding at least two objects when you make the group.
>
> --Graham
>
>
> _______________________________________________
> Drawkit mailing list
> Drawkit at lists.apptree.net
> http://lists.apptree.net/listinfo.cgi/drawkit-apptree.net
More information about the Drawkit
mailing list