Hello every-one,
I have some probleme with SketchUp function and find some help pleaz
I have to update my component with newest but for some reason i cant use classic methode. So i try to erase all of component and insert them with the same transofrmation.
The only problem is that i cant erase the definition, i use many methods and I finish with this :
" definition.entities.erase_entities(definition.entities.to_a)" or “definitions.purge_unused” both of this function doesnt work. I use this on loop and for a reason that I cant understand the loop stop randomly. (after 4, 15 or 7 iteration)
This probleme make my cry if someone can help that would be very nice
You say you “use this on loop”, but didn’t show the loop. If you are deleting inside a loop over the same collection as owns the deleted entities, you are creating a “fence post error”. Most collection structures break if you delete one of their members while iterating over the collection. They then stop at a seemingly random place part way through. The answer is to make a separate Array from the collection and to iterate over that Array. Since you are deleting from the original collection, not the Array, the deletion doesn’t break the iterator.
As a side question, why are t and ents created as Hash objects when you then index them with integer i? An Array would suffice and probably perform better.
Thanks every-one i try this with a new array of definition.name and I loop on this array to delete. It’s work.
I made a mistake and change the hash to array thanks for notice that
Thanks again