Nested block problems

Nested block problems

Anonymous
Not applicable
308 Views
3 Replies
Message 1 of 4

Nested block problems

Anonymous
Not applicable
Hello all,
I've created a routine that will change the color and linetype of a selected layer. For example, I select an object on an xref and that layer gets changed to color 85 and hidden. Well it works perfect except when it comes to blocks that are in the xref. When i select those blocks GetSubEntity goes too "far" and returns layer 0 instead of the layer the block is inserted on. I guess my question is, can you specify how far GetSubEntity digs into nested objects?
0 Likes
309 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
You need to look at the array returned for the ContextData. The last item
will be the xref, the next to last should be the blockref.

wrote in message news:4849195@discussion.autodesk.com...
Hello all,
I've created a routine that will change the color and linetype of a selected
layer. For example, I select an object on an xref and that layer gets
changed to color 85 and hidden. Well it works perfect except when it comes
to blocks that are in the xref. When i select those blocks GetSubEntity goes
too "far" and returns layer 0 instead of the layer the block is inserted on.
I guess my question is, can you specify how far GetSubEntity digs into
nested objects?
0 Likes
Message 3 of 4

Anonymous
Not applicable
Excellent, i knew it had to be something to do with the the contextdata or transmatrix, but the online help is a little bit vague in describing both those. I'll have a look and get back with you if i have any more questions.

Thanks,
Matthew Corbin
0 Likes
Message 4 of 4

Anonymous
Not applicable
Just in case anyone was wondering about my solution I came up with this:

Dim objectID As Long
Dim tempObject As AcadObject
If UBound(ContextData) > 0 Then
objectID = ContextData(0)
Set tempObject = ThisDrawing.ObjectIdToObject(objectID)
Set PickedLayer = ThisDrawing.Layers.Item(tempObject.Layer)
End If

This seems to work just as expected. I tested contextdata to see if it had more the one object.If it does, I will then use the first object in the variant, which turns out to be the block instead of the entity which makes up the block. Therefore giving me the correct layer. Hope this helps out anybody else who has this problem.

Thanks for pointing me in the right direction,
Matthew Corbin
0 Likes