QCAD.org Forum

Discussion forum for contributors and developers who are using the QCAD version 3 ECMAScript development platform or the C++ plugin interface or who are otherwise looking to contribute to QCAD (translations, documentation, etc).

Hi All,I'm new with scripting and till now I have spent several hours reading and studying the scripts.I have experimented with success the use of the Qt api to create custom user interface elements and I'm really impressed by the results.QCAD is really a powerful enviroment. Many thanks to Qt and Andrew.Now I'm facing the QCAD api and I need some help.Reading documentation and the forum it seems that it doesn't exist a unique and persistent identifier for the entities of the drawing (DXF/DWG). Am I correct ?In my project I need to retrieve at different times and also after drawing revisions some entities.

I've tried to use custom properties to store an unique id, but I 'm encountering a problem in my test script.This is an excerpt of my test code :

Using queryEntityDirect the entity is deleted.Using queryEntity the entity is not deleted, but the custom property is not added, QCAD become instable and crash.No problems when I read the custom property ( obviously created with QCAD gui).

queryEntity should be used in this case. queryEntityDirect is faster but should only be used if the entity will not be modified in any way.The call to applyOperation should be outside of the loop (this might have caused the crash).Calling setCustomProperty or setProperty with a custom property ID is equivalent.

Thanks Andrew,yes, I realized to move outside the loop the RAddObjectsOperation creation and applyOperation later this morning.Now I'm looking for a fast way to find an entity with a specific custom properties, but I suppose I have to iterate all the entities.