Delete your scenes via the API - working?
-
I am trying this method but not getting it to work. Is it really implemented? Or am I missing something? my code loks like this:
model = Sketchup.active_model pages = model.pages pages.each do |e| e.erase end
and the error is:(eval):69:in ‘initialize’: undefined method ‘erase’ for #<Sketchup::Page:0x81289e0>What am I missing here, I'm guessing it will be something simple and embarrassing - as usual

Chris
-
e.erase!?? -
I tried it, that didn't work either unfortunately.
-
Read the API carefully - the .erase method is for the Pages class, not the Page class. That's why your code didn't work. Try this:
pages.each{|page| pages.erase(page)}Or, in your style
pages.each do |e| pages.erase(e) end -
Interesting. I had not found it in the API, rather in the blog post here:
What's New in SketchUp 7
Posted by Scott Lininger, SketchUp Team SketchUp 7 contains several improvements to the Ruby API. Here's a quick tour of the best changes. I...
(sketchupapi.blogspot.com)
and the only hint it gives is this:
Delete your scenes via the API
my_page.eraseSo I assumed it was a page thing. Then when I looked for it in the API, it was not in the "page" class section.
So I see it now, and I'll go give it a shot. Thanks Rick,
Chris
-
@chris fullmer said:
Interesting. I had not found it in the API, rather in the blog post here:
What's New in SketchUp 7
Posted by Scott Lininger, SketchUp Team SketchUp 7 contains several improvements to the Ruby API. Here's a quick tour of the best changes. I...
(sketchupapi.blogspot.com)
and the only hint it gives is this:
Delete your scenes via the API
my_page.eraseSo I assumed it was a page thing. Then when I looked for it in the API, it was not in the "page" class section.
So I see it now, and I'll go give it a shot. Thanks Rick,
Chris
Yes, it does give that impression. I can see why it was confusing.
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