Page 1 of 1

The .getData().castToShape() construct ...

Posted: Mon Mar 22, 2021 2:24 pm
by CVH
In 2016 you wrote: ... 048#p15048
The Object.getData().castToShape() construct is generally not a good idea since a data object
is created (but not used) and a pointer to it's shape is retrieved which is well used.
The data object will get deleted by the garbage collector and the pointer will become invalid.

Launched a textual search on the use of '.castToShape()' in my scripts ...
Missed the correct button and the search was in all files. :lol:

Found the construction here:
  • HatchFromSelection.js: HatchFromSelection.traverse() 3x
    Explode.js: Explode.explodeEntity 4x
    qcadscripts.dll: InfoPolylineArea.prototype.pickEntity
Occurred also plenty in my scripts as I have copied the 'shorter' method literally. :oops: