The DataCAD Developer Network (DDN) is an online resource for information and support for DCAL® (DataCAD Applications Language) developers as well as anyone interested in creating fonts, toolbars, hatch patterns, or linetypes for use in DataCAD.
#77595 by dhs
Sat Feb 15, 2020 2:39 pm
I have a scenario where I a macro is storing the address of an entity in a system attribute.
On startup the macro gets the attribute and if it exists then does an ent_get using the lgladdr in the attribute. The behaviour of the macro is then slightly different depending on the return value of the ent_get call.

I have an issue if the entity whose address is stored in the attribute has subsequently been erased: ent_get is still returning true (and the details of the entity are returned in the ent parameter) even though the entity has been erased. (Note: Problem does not occur if PurgeDrawingsOnExit is set to 1 in the ini file and the drawing has been saved since the entity was erased ... ent_get is correctly returning false in this case).

The entity record returned by ent_get for the erased entity appears to be 'correct' (i.e. same as was returned before the entity was erased). The macro actually calls the hi_lite procedure with the returned entity and it is being hilited on the screen as though it had not been erased.

Is there a way to tell that the returned entity has in fact been erased? I don't notice any field in the entity definition that looks like it would indicate the entity was erased (I thought that perhaps the lyr field may be set to nil but that appears to still have the original [undeleted] value). Is it even advisable to store an address like this (or might a file purge move things around?)
Any advice would be appreciated.

Thanks,
David H.
#77600 by Mark F. Madura
Sun Feb 16, 2020 4:10 pm
When an entity gets erased, the entity.next and entity.prev addresses are changed to 'point around' the deleted entity(ies). When the file is closed and saved, the orphans are purged out to reduce file bloat. So, entityA.next should equal entityB.prev and so on.
#77602 by dhs
Sun Feb 16, 2020 4:45 pm
Thanks very much for your comments Mark,

It is obvious that my original logic (of simply storing an address in a system attribute) is not a valid approach. There is no easy and reliable way to tell if the entity retrieved via a stored address has in fact been deleted, or even if it is still the same entity that was originally identified.
I will modify my logic as per my previous post, so this is no longer an issue for me.

Who is online

Users browsing this forum: No registered users and 31 guests

About DataCAD Forum

The DataCAD Forum is a FREE online community we provide to enhance your experience with DataCAD.

We hope you'll visit often to get answers, share ideas, and interact with other DataCAD users around the world.

DataCAD

Software for Architects Since 1984