Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
🛣️ Road Profile Builder | Generate roads, curbs and pavements easily  Download 
Delete All Scenes with API Question...
- 
Hi,
Why the following code only deletes some scenes and not all?
model = Sketchup.active_model pages = model.pages pages.each {|page| pages.erase(page)}A workaround for this issue is...
model = Sketchup.active_model pages = model.pages delete_list = [] pages.each {|page| delete_list << page} delete_list.each {|page| pages.erase(page)}But still, I ask why did the first example fail to deliver?
Shortly after this I post stumbled upon this TOPIC and it explained the issue.
 - 
When you iterate a collection - like pages, or selection or entities, and change that collection's contents - e.g. by deleting something - then you get issues because the collection changes as a result.
BUT if you 'freeze' the collection, but using.to_aOR perhaps you collect items, which are then deleted afterwards, after you exit using the collection... then it avoids the issue. 
Advertisement