I am going to download models and import them to Sketchup. Is it possible to get an empty scene for that with Ruby API?
There is no “empty” scene.
Very-very simplified: The scenes just a kind of other views of the current model with some additional useful properties.
For historical reason the Scene
called as Page
in Ruby.
Pages#add-instance_method is used to add a new Page object to the collection.
See also:
https://ruby.sketchup.com/Sketchup/Model.html#pages-instance_method
https://ruby.sketchup.com/Sketchup/Page.html
https://ruby.sketchup.com/Sketchup/Pages.html
Thank you Dezmo. I tried Pages#add. Yes, it was creating a new scene. Actually I want to open an empty .skp file to draw models on it. Detailed steps:
-
Close the current model. If there are modifications not yet saved, pop up a dialog to notify the user to save before.
-
Open an empty model.
This will be done by SketchUp automatically.
FYI, you can test whether the model has been modified …
You can also create a new component definition, draw to it’s entities collection and save the definition out as an SKP file (so it can be imported into other models.)
Sketchup::ComponentDefinition
classSketchup::DefinitionList
collectionSketchup::Model#definitions
method
Perfect! That’s exactly what I want.