Ruby Architecture concerning Deleted Entities
-
Sketchup deletes and replaces entities as it desires - sometime from one ruby line to the next.
I am trying to build fast routines avoiding to to manipulations which would necessarily lead to new entities (however - if SU decides to do so I obviously can't stop it from doing so).
sumod = load_skp_entities_from_file("xxx.skp")
lets assume, ents is loaded as a Sketchup::ComponentInstance, then the reference to its entities is:
ents = sumod.definition.entities
now I need to work with those entities in order to make changes to the loaded model.
at one point in the code I run into the following part:
return if ents.deleted? # ents.deleted? is false
puts ents.lengthand sketchup breaks with "undefined method `length' for #<Deleted Entity:0xef91fd8>"
in THE VERY NEXT LINE after having checked that it is NOT deleted.
and there is no chance to get information on how why when or how to avoid thisthe only comments I found were: "why work with entities, create new ones right away as you need them". this is not how my code works for many good reasons (like not having to model and especially correctly texturize from scratch). It really needs to load entities and work with them.
Are there any guidelines, help on how to keep entity references (or meta references) valid in a fast and efficient way?
Advertisement