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.
Solved! Go to Solution.
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
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?
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.
Can't find what you're looking for? Ask the community or share your knowledge.