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 viewtopic.php?f=30&t=1546).
- Referenced block names are not unique (one block, more blockreferences).
Any suggestions?
Thank you
Ciao
Mario
blockReference permanent identifier
Moderator: andrew
Forum rules
Always indicate your operating system and QCAD version.
Attach drawing files, scripts and screenshots.
Post one question per topic.
Always indicate your operating system and QCAD version.
Attach drawing files, scripts and screenshots.
Post one question per topic.
-
- Junior Member
- Posts: 19
- Joined: Thu Nov 29, 2012 4:28 pm
-
- Junior Member
- Posts: 19
- Joined: Thu Nov 29, 2012 4:28 pm
Re: blockReference permanent identifier
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
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
Re: blockReference permanent identifier
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.
-
- Junior Member
- Posts: 19
- Joined: Thu Nov 29, 2012 4:28 pm
Re: blockReference permanent identifier
Ok, it is working wothout any problems.
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:
Thank you.
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];
}
Re: blockReference permanent identifier
Excellent! Thanks for sharing your solution.