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.erase
So 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.erase
So 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.
Advertisement