I am trying to modify any Polyline XData if and only if its position, area, or shape (changes in vertices) is changed.
What are the possible ways to do this in AutoCAD?
Thanks in advance for your help
When you are using XData, some DXF codes are transformed with their owner. You can use the codes: ExtendedDataWorldXCoordinate
(1011), ExtendedDataWorldXDisp
(1012), ExtendedDataWorldXDir
(1013), ExtendedDataDist
(1041) and ExtendedDataScale
(1042).
However, in your case, I will use the Database.ObjectModified
or DBObject.Modified
events. You can use this approach to find which properties have been modified.
In order to get good performance, you should use an ObjectOverrule
where you will override the Open
method, save the state of your polyline if it is opened for Write and compare it to the state found in the Close
method. Then you can change your XData in a CommandEnded
event handler in order to be safe.
You can also use the DBObject.OpenedForModify
and the DBObject.ObjectClosed
events.
In fact, there is a lot of ways to do it, but the ObjectOverrule
seems to be the best option, as you can set a filter on the XData. And when you override the Close
method, you have direct access to the object and its state whereas in the DBObject.ObjectClosed
event, you only have the Id.