Hi,
I want to write an overrule to automaticly suppress xrecords in extension dictionary while copiing
but then I test my module, the xreocrd is supressed in the original piece , not the newest one !!
canyou help me and find that I am doing false ?
attached is my project and a dwg for testing
regards
Luc
Hi Luc,
Sorry for the delay.
I have tried your sample project and it seems to be working ok.
After I copy and paste the rectangle in the drawing, the dictionary named "IdProfil" was not part of the copied entity and its XData was also cleared.
I am using AutoCAD 2014 to try this.
Can you please provide more information to reproduce the problem ?
Regards,
Balaji
Hi Balaji
after testing , I found this
using copy + paste , the sample work ok
using then copy command, the sample work false like explained
, the xrecord is suppressed for the original rectangle , not the copy
I am using Autocad 2014 and visual studio 2012.
regards
Luc
Hi Luc,
Sorry for the delay.
I could reproduce this behavior and haven't found a way to overcome it.
I have contacted our engineering team about this and will get back to you.
Regards,
Balaji
If you want to supress copying of certain XRecords in a DBDictionary, you overrule the XRecord class, not the DBDictionary class, and when DeepClone() is called on the XRecord that you don't want to be cloned, you only need to skip the call to MyBase.DeepClone().
Using a Transaction, and removing elements from a DBDIctionary from within the DeepClone() override should really be avoided. Another way to deal with the problem without requiring overrules is by handling the deep-clone related events of the Database, and simply remove items from the IDMap that you don't want cloned.
As DP suggested, overruling the Xrecord would definitely be a better approach for this.
Unfortunately, the same behavior seems to exist when I tried that approach. It works ok when the entity is copied and pasted using Ctrl+C / Ctrl+V. But when the "Copy" command is used, the Xrecord gets removed from the original entity and not from the cloned one.
This is strange but I am not yet sure about the reason for this behavior.
I found a workaround for it by not using the ObjectOverrule when the DeepClone context is “Copy”.
In that case, the Xrecord is removed using the “DeepCloneEnded” event handler.
The ObjectId of the pasted entity is retrieved from the idMap in “BeginDeepCloneTranslation” event.
This is working ok for “CopyClip” and “Copy” commands.
I have attached a sample code. To try this :
1. Create a circle
2. Run the "Test" command and select the circle. This creates the Xrecord in the entity's extension dictionary.
3. Use "Copy" command or "CopyClip" command
Regards,
Balaji
@Balaji_Ram wrote:
I found a workaround for it by not using the ObjectOverrule when the DeepClone context is “Copy”.
In that case, the Xrecord is removed using the “DeepCloneEnded” event handler.
If I recall correctly, preventing an object from being cloned using the deep-clone events should only require you to remove the corresponding entry from the IDMap passed into the BeginDeepCloneTranslation event handler, which should prevent the object from being cloned in the first place, and hence, not require you to remove the XRecord from the cloned owner after the fact.
Hi DP,
I have attached the file which was my attempt at overruling the cloning of Xrecord. But it seemed to have the same problem as what Luc had originally mentioned.
About removing the id from the BeginDeepCloneTranslation, yes that should work. But I haven't tried it and my thought was only revolving around making the overruling method work 🙂
Regards,
Balaji
Can't find what you're looking for? Ask the community or share your knowledge.