Save file with only selected components

It is possible to save a File with only the seletected components ? I’ve readed the Class: Sketchup::Model and i found the:

status =

but it save the entire project, and i want to save the project with only the selected components.

But do you wish to still keep the current file as is ?

If so, there are several ways to do this.

  1. Save a copy of the current file, then open it, and delete everything that was not an instance of the selected components (by name.) Then purge the model’s collections of unused stuff. And save the new state of the copy.

  2. Save out the definitions to individual skp files, save a set of transformations for the instances saved. Open a new blank model, load the saved out files into the new model’s definition collection, then recreate the instances using the saved transforms. Lastly save the new model.

If not. Just delete everything that was not selected, and purge the model’s collections of unused stuff.
ie …

if model.active_entities != model.entities
  active_to_keep = selection.to_a.delete_if { |e|
  active_to_go = model.active_entities.to_a - active_to_keep
to_keep = selection.to_a.delete_if {|e| !model.entities.include?(e) }
to_go = model.entities.to_a - to_keep
# Purge collections in definitions, layers and then materials order.

You saved my life, i do not need to keep the current file, this works perfectly in what i need
Thank you

1 Like