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.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement