Hi Andrew,
I have a script which allows a user to create two entities, a circle and some text. The circle entity has some custom properties that are created when the script is run. The text depicts (in textual form) what the circles type is, for example type a, b, c etc.
The user is to be allowed to change some of the custom properties of the circle entity via our dialog box (not the QCAD properties editor) and I need to be able to change the text entity (associated with the circle) when this happens.
I thought a way to do this would be to add a custom property to the circle entity that holds the text entities id (or handle) but whenever I try to set the value getId() always returns an id of -1, however QCAD property editor lists a correct handle.
I have tried setting the value before and after the applyOperation but still get the same result.
Do you have any idea why getId might return -1?
Edit:
I meant to add I may look into creating a block at some point to group the two items together but I am not sure if this will cause me other issues down the line.
Thanks,
Andrew.
[Solved] Getting an entities id or handle returns -1
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.
[Solved] Getting an entities id or handle returns -1
Last edited by Taygete on Fri Sep 12, 2014 6:59 am, edited 1 time in total.
Re: Getting an entities id or handle returns -1
It appears the issue I was having is because (I think) I was trying to get the entities ids too early and it had not been set.
I resolved this the other day by using the transaction returned from applyOperation(...) and setting the ids accordingly.
I resolved this the other day by using the transaction returned from applyOperation(...) and setting the ids accordingly.
Code: Select all
var transaction = di.applyOperation(...);
var ids = transaction.getAffectedObjects();
var committedEntity = document.queryEntity(ids[0]);
...