.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Change Block Reference Block

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
dwi_it
1047 Views, 3 Replies

Change Block Reference Block

Is it possible to change the block a block reference is pointing to?

 

In my code I'm trying to intercept when certain block refs are copied and replace them with a reference to another block. I'm handling the ObjectAppended event of the database. I've tried creating a new block ref to the new block and erasing the DBObject that was passed to the ObjectAppended event, but the position of the object is not set at that point, so my replacement block ref always ends up on top of the old object, not at the destination point given to the copy command.

3 REPLIES 3
Message 2 of 4
caddzone
in reply to: dwi_it

The ObjectAppended event is definitely not the event to use

for your needs.

 

One way to do this would be to handle each Database's

BeginDeepCloneTranslation event.

 

In your event handler you can walk through the IDMapping that's

passed in the event arguments, and open and modify each copied

object. For simple blocks, you would set the BlockTableRecord

property of each BlockReference that you need to change, and

that's it.

 

This example shows the basics of using that event:

    http://www.caddzone.com/DeepCloneExample.cs



AcadXTabs for AutoCAD
Supporting AutoCAD 2000-2011


Message 3 of 4
dwi_it
in reply to: caddzone

Cool, that's exactly the property I was looking for and couldn't find.

 

If you could explain though, what's the reason why  BeginDeepCloneTranslation would be better for this situation?

Message 4 of 4
caddzone
in reply to: dwi_it

Because that event fires whenever objects are copied, which is

the event you're interested in, and because you can access and

modify the objects from the handler of the event, rather than having

to wait for a command to end.

 



AcadXTabs for AutoCAD
Supporting AutoCAD 2000-2011


Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost