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 :
var di = this.getDocumentInterface();
var document = this.getDocument();
// find all selected entities:
var ids = document.querySelectedEntities();
var op = new RAddObjectsOperation();
for (i=0; i<ids.length; i++)
var id = ids[i];
var entity = document.queryEntityDirect(id);
//var entity = document.queryEntity(id);
entity.setProperty(new RPropertyTypeId("TEST"), 25);
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).
I'm using QCAD-PRO with a Mac (open -n QCAD-Pro.app --args -enable-script-debugger -enable-xdata ) :
QCAD version: 220.127.116.11
Date: Nov 12 2013
Qt version: 4.8.4
Compiler version: gcc 4.2.1
OS version: Mac OS X 10.7
Hope somebody out of here is able to kick me in the right direction.