Eneroth Merge Layer

@eneroth3, is there a way to modify your Merge Layers plugin to stay open after merging a layer until you close it manually? This would be helpful if merging multiple layers at once. I creating a new layer naming system and need to go back through my old models to update to the new standard. Also, is there any way to add the functionality to keep the old layer’s scene tag visibility so you do not have to go back through and update the scenes or use the Auto-Invisible Layer?

Thanks so much for all of your great plugins!

Currently this extension uses a UI.inputbox for the input, which is a modal element. It pauses the execution of SketchUp until it gets input from the user.

You could use a snippet like this if you want to merge multiple layers, and always the same layers. Replace the example names by your actual layer names, and add as many lines as you need.

model = Sketchup.active_model
layers = model.layers

model.start_operation("Merge Custom Layers")
# Source layer -> target layer
EneMergeLayers.perform_merge(layers["Layer B"], layers["Layer A"])
EneMergeLayers.perform_merge(layers["Layer C"], layers["Layer A"])
model.commit_operations

You can run this from the Ruby Console, or you can save it to a text file, install Eneroth Script Runner, and just drag that file onto SketchUp to run the script.

I don’t quite follow the part about layer visibility. What visibility do you want copied where?

Thanks Christina! I will give that a go. As far as scene visibility, here is an example:

Let’s say I am replacing Tag “OB_Windows” with Tag “4.18_Windows”. The scenes that are already set up in the model have tag visibilities already set for “OB_Windows”. The new Tag, “4.18_Windows” can only be brought in as “on in all scenes” or “off in all scenes” using Auto-Invisible plugin. So what I am wondering if there’s a way that Tag “4.18_Windows” could inherit the scenes tag visibility of “OB_Windows” I am replacing so I don’t have to go through and update all the scenes manually for tag visibility.

Could I also use a script to add several Tag Folders automatically?

@eneroth3, would the script look like this then?

model = Sketchup.active_model
layers = model.layers

model.start_operation(“Merge Custom Layers”)
# Source layer → target layer
EneMergeLayers.perform_merge(layers[“SP_ALWAYS OFF”], layers[“0.01_Always Off”])
EneMergeLayers.perform_merge(layers["SP_2D”], layers[“0.02_2D”])
EneMergeLayers.perform_merge(layers["SP_3D”], layers[“0.03_3D”])
EneMergeLayers.perform_merge(layers["SP_BACKGROUND”], layers[“0.04_Background”])
EneMergeLayers.perform_merge(layers["Location Snapshot”], layers[“0.05_Import:Image”])
EneMergeLayers.perform_merge(layers["Location Terrain”], layers[“0.06_Import:Terrain”])
EneMergeLayers.perform_merge(layers["SP_SECTION CUT LW”], layers[“0.08_Section LW”])
EneMergeLayers.perform_merge(layers["SP_SECTION PLANES”], layers[“0.09_Section Planes”])
EneMergeLayers.perform_merge(layers["X_HIDDEN LAYERS”], layers[“0.10_Locked Tags”])
EneMergeLayers.perform_merge(layers["LEVEL_00”], layers[“01.02_Foundation”])
EneMergeLayers.perform_merge(layers["LEVEL_01”], layers[“1.03_First Floor”])
EneMergeLayers.perform_merge(layers["LEVEL_02”], layers[“1.04_Second Floor”])
EneMergeLayers.perform_merge(layers["LEVEL_03”], layers[“1.05_Third Floor”])
EneMergeLayers.perform_merge(layers["LO_1_EXTERIOR”], layers[“2.01_Exterior”])
EneMergeLayers.perform_merge(layers["LO_2_INTERIOR”], layers[“2.02_Interior”])
EneMergeLayers.perform_merge(layers[“LO_3_HOUSE”], layers[“2.03_House”])
EneMergeLayers.perform_merge(layers[“LO_4_GARAGE”], layers[“2.04_Garage”])
EneMergeLayers.perform_merge(layers[“SP_BUILDING MODEL”], layers[“2.05_Building Model”])
EneMergeLayers.perform_merge(layers[“LO_BUILDING MODEL”], layers[“2.05_Building Model”])
EneMergeLayers.perform_merge(layers[“COND_DEMO”], layers[“3.01_Demo”])
EneMergeLayers.perform_merge(layers[“COND_EXISTING”], layers[“3.02_Existing”])
EneMergeLayers.perform_merge(layers[“COND_NEW”], layers[“3.03_New”])
EneMergeLayers.perform_merge(layers[“OB_CEILINGS”], layers[“4.01_Ceilings”])
EneMergeLayers.perform_merge(layers[“OB_DECKS/PATIOS”], layers[“4.02_Decks/Patios”])
EneMergeLayers.perform_merge(layers[“OB_DETAIL”], layers[“4.03_Detail”])
EneMergeLayers.perform_merge(layers[“OB_DOORS”], layers[“4.04_Doors”])
EneMergeLayers.perform_merge(layers[“OB_FLOORS”], layers[“4.05_Floors”])
EneMergeLayers.perform_merge(layers[“OB_FOOTINGS”], layers[“4.06_Footings”])
EneMergeLayers.perform_merge(layers[“OB_FURNITURE”], layers[“4.07_Furniture”])
EneMergeLayers.perform_merge(layers[“OB_GUTTERS”], layers[“4.08_Gutters”])
EneMergeLayers.perform_merge(layers[“OB_HARD SURFACES”], layers[“4.09_Hard Surfaces”])
EneMergeLayers.perform_merge(layers[“OB_POSTS/BEAMS”], layers[“4.10_Posts/Beams”])
EneMergeLayers.perform_merge(layers[“OB_ROOFS”], layers[“4.11_Roofs”])
EneMergeLayers.perform_merge(layers[“OB_SIDING”], layers[“4.12_Siding”])
EneMergeLayers.perform_merge(layers[“OB_STAIRS”], layers[“4.13_Stairs”])
EneMergeLayers.perform_merge(layers[“OB_TRIM”], layers[“4.16_Trim”])
EneMergeLayers.perform_merge(layers[“OB_WALLS”], layers[“4.17_Walls”])
EneMergeLayers.perform_merge(layers[“OB_WINDOWS”], layers[“4.18_Windows”])
EneMergeLayers.perform_merge(layers[“OB_APPLIANCES”], layers[“5.01_Appliances”])
EneMergeLayers.perform_merge(layers[“OB_CABINETS”], layers[“5.02_Cabinetry”])
EneMergeLayers.perform_merge(layers[“OB_COUNTERTOPS”], layers[“5.03_Countertops”])
EneMergeLayers.perform_merge(layers[“OB_MECHANICAL”], layers[“5.07_Mechanical”])
EneMergeLayers.perform_merge(layers[“OB_LIGHTING”], layers[“5.08_Electrical”])
EneMergeLayers.perform_merge(layers[“OB_PLUMBING”], layers[“5.09_Plumbing”])
EneMergeLayers.perform_merge(layers[“OB_PLUMBING FIXTURES”], layers[“5.09_Plumbing”])
model.end_operations

I am getting this error:
Error: #<SyntaxError: :6: syntax error, unexpected float literal, expecting ‘]’>
SketchUp:in `eval’
=> nil

Most probably you are using the wrong character for " (quotation mark)
Moreover there is a mistake in last line of @eneroth3 code
model.end_operations it should be model.commit_operation

Try this:

model = Sketchup.active_model
layers = model.layers

model.start_operation("Merge Custom Layers")
# Source layer → target layer
EneMergeLayers.perform_merge(layers["SP_ALWAYS OFF"], layers["0.01_Always Off"])
EneMergeLayers.perform_merge(layers["SP_2D"], layers["0.02_2D"])
EneMergeLayers.perform_merge(layers["SP_3D"], layers["0.03_3D"])
EneMergeLayers.perform_merge(layers["SP_BACKGROUND"], layers["0.04_Background"])
EneMergeLayers.perform_merge(layers["Location Snapshot"], layers["0.05_Import:Image"])
EneMergeLayers.perform_merge(layers["Location Terrain"], layers["0.06_Import:Terrain"])
EneMergeLayers.perform_merge(layers["SP_SECTION CUT LW"], layers["0.08_Section LW"])
EneMergeLayers.perform_merge(layers["SP_SECTION PLANES"], layers["0.09_Section Planes"])
EneMergeLayers.perform_merge(layers["X_HIDDEN LAYERS"], layers["0.10_Locked Tags"])
EneMergeLayers.perform_merge(layers["LEVEL_00"], layers["01.02_Foundation"])
EneMergeLayers.perform_merge(layers["LEVEL_01"], layers["1.03_First Floor"])
EneMergeLayers.perform_merge(layers["LEVEL_02"], layers["1.04_Second Floor"])
EneMergeLayers.perform_merge(layers["LEVEL_03"], layers["1.05_Third Floor"])
EneMergeLayers.perform_merge(layers["LO_1_EXTERIOR"], layers["2.01_Exterior"])
EneMergeLayers.perform_merge(layers["LO_2_INTERIOR"], layers["2.02_Interior"])
EneMergeLayers.perform_merge(layers["LO_3_HOUSE"], layers["2.03_House"])
EneMergeLayers.perform_merge(layers["LO_4_GARAGE"], layers["2.04_Garage"])
EneMergeLayers.perform_merge(layers["SP_BUILDING MODEL"], layers["2.05_Building Model"])
EneMergeLayers.perform_merge(layers["LO_BUILDING MODEL"], layers["2.05_Building Model"])
EneMergeLayers.perform_merge(layers["COND_DEMO"], layers["3.01_Demo"])
EneMergeLayers.perform_merge(layers["COND_EXISTING"], layers["3.02_Existing"])
EneMergeLayers.perform_merge(layers["COND_NEW"], layers["3.03_New"])
EneMergeLayers.perform_merge(layers["OB_CEILINGS"], layers["4.01_Ceilings"])
EneMergeLayers.perform_merge(layers["OB_DECKS/PATIOS"], layers["4.02_Decks/Patios"])
EneMergeLayers.perform_merge(layers["OB_DETAIL"], layers["4.03_Detail"])
EneMergeLayers.perform_merge(layers["OB_DOORS"], layers["4.04_Doors"])
EneMergeLayers.perform_merge(layers["OB_FLOORS"], layers["4.05_Floors"])
EneMergeLayers.perform_merge(layers["OB_FOOTINGS"], layers["4.06_Footings"])
EneMergeLayers.perform_merge(layers["OB_FURNITURE"], layers["4.07_Furniture"])
EneMergeLayers.perform_merge(layers["OB_GUTTERS"], layers["4.08_Gutters"])
EneMergeLayers.perform_merge(layers["OB_HARD SURFACES"], layers["4.09_Hard Surfaces"])
EneMergeLayers.perform_merge(layers["OB_POSTS/BEAMS"], layers["4.10_Posts/Beams"])
EneMergeLayers.perform_merge(layers["OB_ROOFS"], layers["4.11_Roofs"])
EneMergeLayers.perform_merge(layers["OB_SIDING"], layers["4.12_Siding"])
EneMergeLayers.perform_merge(layers["OB_STAIRS"], layers["4.13_Stairs"])
EneMergeLayers.perform_merge(layers["OB_TRIM"], layers["4.16_Trim"])
EneMergeLayers.perform_merge(layers["OB_WALLS"], layers["4.17_Walls"])
EneMergeLayers.perform_merge(layers["OB_WINDOWS"], layers["4.18_Windows"])
EneMergeLayers.perform_merge(layers["OB_APPLIANCES"], layers["5.01_Appliances"])
EneMergeLayers.perform_merge(layers["OB_CABINETS"], layers["5.02_Cabinetry"])
EneMergeLayers.perform_merge(layers["OB_COUNTERTOPS"], layers["5.03_Countertops"])
EneMergeLayers.perform_merge(layers["OB_MECHANICAL"], layers["5.07_Mechanical"])
EneMergeLayers.perform_merge(layers["OB_LIGHTING"], layers["5.08_Electrical"])
EneMergeLayers.perform_merge(layers["OB_PLUMBING"], layers["5.09_Plumbing"])
EneMergeLayers.perform_merge(layers["OB_PLUMBING FIXTURES"], layers["5.09_Plumbing"])
model.commit_operation
2 Likes

Now I am getting this error:

Error: #<ArgumentError: cannot remove default tag>
/Users/kevingalyen/Library/Application Support/SketchUp 2022/SketchUp/Plugins/ene_merge_layers/main.rb:19:in remove' /Users/kevingalyen/Library/Application Support/SketchUp 2022/SketchUp/Plugins/ene_merge_layers/main.rb:19:in perform_merge’

:9:in `' SketchUp:in `eval' => nil

According to the message the Extension is trying to remove the default tag “Untagged”… I have no idea why. (I do not have this Extension downloaded)
Only one thing I can guess:
Didn’t you give a “Untagged” as Source layer?

Be aware: Unlike layers, folders do not need to have a unique name. Therefore there will be two "Tag folder 1" in a model if you run the script below…
(Assigning the existing Tag structure into folder needs to done manually …)

def add_folder(folder_names)
  model = Sketchup.active_model
  manager = model.layers
  model.start_operation("Add Tag Folders")
  folder_names.each{|name|
    manager.add_folder(name)
  }
  model.commit_operation
end
folder_names = [ "Tag folder 1", "Tag folder 1", "Tag folder A" ]
add_folder(folder_names)

For that I’d try simply renaming the tag. The script is needed when merging more than one tag I to one.

You can look up how to change layer names in the SketchUp Ruby API docs, and make a quick script that rename them for you.

This suggests one or more of the names you provided isn’t used by any layer.