Hi,
Newly added entities or objects do not yet have a valid ID if they were added within a transaction.
(We will look that up in a minute)
They are only created in group at the end of the transaction.
bob wrote: ↑Wed Jun 15, 2022 7:32 pm
Can I not surround these draw functions with that?
Yes you could, but only useful with a group of actions.
Every action is followed by a screen update and much more than that
With a grouped transaction just one update instead of one each action.
bob wrote: ↑Wed Jun 15, 2022 7:32 pm
How to get handles if you do that?
You need to re-query the entity(ies)/object(s).
The simplified API of QCAD is intended to do basic things in an easy way.
I think you may want to get deeper into scripting under QCAD
A reference of the open source:
https://qcad.org/doc/qcad/3.0/developer/annotated.html
Scripts can be found on GitHub:
https://github.com/qcad/qcad
About ID=-1 ...
simple.js :
https://github.com/qcad/qcad/blob/087f4 ... _create.js
-
function addPolyline(points, closed, relative) creates a polyline shape called
pl and returns
addShape(pl).
-
function addShape(shape, color, linetype, lineweight) creates a polyline entity for the document and returns
addEntity(entity).
In the above we have the first remark on IDs within transactions
(Also:
https://qcad.org/doc/qcad/3.0/developer ... ba88080a01)
-
function addEntity(entity) returns
addObject(entity) and that will add the object and return a reference to it.
Further mind that the ID and the handle is not the same but you can get the handle by the entity ID at runtime.
There are numerous examples of scripts in the GitHub repository
Regards,
CVH