Copy entities to clipboard and paste them in a new model



Is it possible to copy entities to the clipboard so that they can be pasted in a new model? This is the scenario:

  1. I have a baseline model with some fixed entities (e.g. existing buildings). The user can add ‘additional’ entities to this baseline model to represent different scenarios (e.g. new buildings)
  2. Each time the user creates a new scenario he/she should re-start from the fixed baseline model. In order to do this I delete all the entities that have been added, save the model and create a new baseline model ready for modifications.
  3. I would like to copy the entities that are being removed to the clipboard so that the user can paste them in the newly created baseline model.

I have tried the following:

sel = Sketchup.active_model.selection
sel.add entities_to_be_removed
Sketchup.send_action "copy:"

The selection works correctly, but it seems that the clipboard is cleared when I switch to the new model.

Is this the case? Can you suggest an alternative? Thanks


Yes. Save the entities array to a component file. Then insert it into the other model.

  dlist = Sketchup::active_model.definitions
  cdef = dlist.add("Removed Entities")
  grp = cdef.entities.add_group(entities_to_be_removed)


  cdef = nil
  dlist = Sketchup::active_model.definitions
    cdef = dlist.load("myfile.skp")
  ents = Sketchup::active_model.entities
  inst = ents.add_instance(


I can’t follow the logic of your scenario…

in 1 you seemingly supply baseline.skp, and the user adds additional items?

if so, in 2 using ‘save_as’ with a new name the resulting file [ baseline.skp + added items ] is already what you outline as your goal in 3…

each subsequent time you ‘save_as’ the original is retained and the active model switches to the new one…

you appear to be trying to reinvent the wheel [ no offence intended ]



The script is used to perform simulations. These simulations have other input parameters independent from the SU entities.

The baseline.skp actually contains:

  1. The original (fixed) buildings
  2. A group of faces where the simulations (solar, CFD) have to performed. This is the Area of Interest. As I am working on potentially large masterplan I need to limit the size of the calculation domain.
  3. A series of input parameters for the simulation (duration, mesh size, etc).

In addition to the above the scenario.skp contains entities that represent other elements such obstructions, shading, new buildings, etc.

Say the the user is in the scenario.skp and has already added a few additional entities and saved the scenario. At this point he/she wants to create a new baseline.skp for a different analysis with different group of faces on which to perform the simulation (new area of interest). At the moment I delete all the entities that have been added except the ‘new’ area of interest and create a new baseline.skp.

I was looking for a way to keep the entities that have been deleted and give the user the option to use them as a starting point for the new scenario associated with the new analysis.

The rational behind this is to force a comparison between scenarios with a common set of parameters, area of interest, mesh density etc…

All this said though, you actually made me think that there could be a better way to do this. The code has been structured in this way for over a year so maybe a fresh look could be useful.



thanks for the thanks, glad my confusion may be of benefit…

another question, based on your other threads, I assume your solution needs it to be cross platform?



Ideally yes.

However I think the solution proposed by Dan could be a good alternative. I would save the deleted entities in a temporary folder and give the user the option to import them once the new baseline.skp has been created.