blockReference permanent identifier

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).

Moderator: andrew

blockReference permanent identifier

Postby mariosboarina » Mon Jan 21, 2013 6:40 pm

Hi,
I can't find a way to permanently identify a blockReferenceEntity. I need it as key to an external xml db.
- I tried both Id and Handle, but they change on save-close-reopen of QCad; Id always changes, Handle changes after modification to other elements of the drawings (adding blocks).
- It's better not to assign permanent custom properties with XData enabled (see other post http://www.qcad.org/rsforum/viewtopic.php?f=30&t=1546).
- Referenced block names are not unique (one block, more blockreferences).
Any suggestions?

Thank you
Ciao
Mario
mariosboarina
Junior Member
 
Posts: 19
Joined: Thu Nov 29, 2012 4:28 pm

Re: blockReference permanent identifier

Postby mariosboarina » Mon Jan 28, 2013 11:59 am

Ok, I surrender, I think there's no solution, I didn't find any :(
I'll try attaching an XData to interested entities and then query for them on drawing opening, hoping this isn't going to cause compatibility problems. As a consequence I'll have to start QCad within a .bat, with the -enable-xdata option.
Mario
mariosboarina
Junior Member
 
Posts: 19
Joined: Thu Nov 29, 2012 4:28 pm

Re: blockReference permanent identifier

Postby andrew » Mon Jan 28, 2013 9:09 pm

Yes, XData might be the best way for now. If the XData handing of QCAD changes, there will still be a way to query and adjust existing XData. Just the user interface and API might be different in the future. I would recommend to encapsulate all XData related functionality in some helper functions (e.g. setXData(entity, data...), getXData(entity) to make future updates easier.
User avatar
andrew
Site Admin
 
Posts: 2603
Joined: Fri Mar 30, 2007 6:07 am

Re: blockReference permanent identifier

Postby mariosboarina » Fri Feb 08, 2013 3:59 pm

Ok, it is working wothout any problems. :D
I saved and resored after reopening an integer ID for some blockRefs.
I'm testing it since days and non problem outcame.
I've also tried exporting in Autocad, modifing and re-importing it, and all is fine.

Here's the snippet I tried out:

Code: Select all
MyCommand.prototype.setEntityProperty = function(entity, propID, prop) {
   entity.setProperty(propID, prop);
   var di = this.getDocumentInterface();
   var operation = new RAddObjectsOperation(false);
    operation.addObject(entity);
    di.applyOperation(operation);
}


MyCommand.prototype.getEntityProperty = function(entity, propID) {
   var prop =  entity.getProperty(propID);
   return prop[0];
}


Thank you.
mariosboarina
Junior Member
 
Posts: 19
Joined: Thu Nov 29, 2012 4:28 pm

Re: blockReference permanent identifier

Postby andrew » Sat Feb 09, 2013 1:01 am

Excellent! Thanks for sharing your solution.
User avatar
andrew
Site Admin
 
Posts: 2603
Joined: Fri Mar 30, 2007 6:07 am


Return to QCAD 3 Developers and Contributors

Who is online

Users browsing this forum: Majestic-12 [Bot] and 3 guests