I am working on a model with many components at the moment and now comes the dreaded part of creating the Layout document specifying each component. So I was wondering - is there a plugin or something that creates a unique Tag/Layer for each selected component and places the component on that layer.
That would make it super easy to modify which parts to show and which parts to hide in Layout.
I can do this by hand of course but it feels like an task for a trained monkey that needs punishment.
I made some…first for test. To see if it is what you want?
No warranties! Use your own risk! But it should work…
See animation below too:
Open Ruby console and copy-paste the code below to it and hit Enter (Return)
If you select something and it contains one or more components, you will get a context menu (right mouse click) “Add Tag/Layer to selected comps by def name”
The component instances will get a Tag/Layer association, where a Tag/layer name same as the component definition name.
You can undo it.
See animation:(Click on it if not animating…)
module Dezmo
module TagByComp
extend self
@@loaded = false unless defined?(@@loaded)
def add_Tag_to_comp_by_name
mod = Sketchup.active_model
sel = mod.selection
layers = mod.layers
mod.start_operation("Add Tag/Layer to selected comps by def name", true)
sel.grep(Sketchup::ComponentInstance){|e|
def_name = e.definition.name
layer = layers.add(def_name)
e.layer = layer
}
mod.commit_operation
end
unless @@loaded
UI.add_context_menu_handler do |context_menu|
if Sketchup.active_model.selection.grep(Sketchup::ComponentInstance).first
context_menu.add_item("Add Tag/Layer to selected comps by def name"){
add_Tag_to_comp_by_name()
}
end
end
@@loaded = true
end
end
end
You are welcome! I will wrap it to “real extension” later today , and post the .rbz file here. It will be unsigned , but you can install as usual.
(most probably will happen at the evening, EU time)
Nice. I’ve been using Sketchup since - I think 2008. We are a small boat yard somewhere close to Berlin - building all sorts of stuff that was designed in Sketchup - here an example of one of our latest projects - so you know what it goes into. Lot’s of detailing ahead of me - this baby needs to swim by March next year…
Dezmo_tag_by_comp.rbz (10.4 KB)
Create Tag/Layer and associate to selected component instances by it’s definition names.
There will be no “main” menu but a toolbar icon and context menu.
If you select something and it contains one or more components, you will get a context menu (right mouse click) “Add Tag/Layer to selected comps by def name”
The toolbar icon will be enabled with a similar manner.
Shortcut can be assigned, considering the above mentioned selection criteria.
If there is a Tag/Layer already in a model it will be considered and used.
If the Tag/Layer is already associated to instance there will be no changes.
If the component instance definition renamed, you have to run the plugin again to get it’s Tag/Layer again, however the “old” Tag/Layer will not be removed. You can purge it yourself.
No warranties! Use your own risk! But it should work…
Bugs can be reported here. I’ll do my best, considering priority of my private life!
It’s beautiful. It’s also - the more I think about it - a perfect workaround for an absolutely silly shortcoming of the Sketchup/Layout workflow. WHY do you need to write this? I mean - we already have the outliner and we already know all the components. The only reason this marvelous plugin is necessary is because you cannot hide / unhide elements from the outliner in Layout. So here I am hoping that this plugin will be obsolete one day. For now - it will save me hours on many days to come!
This plugin IS beautiful. This is even better than writing Tag name directly into the Entity box which I was freaked out didn’t work suddenly in SU 2021.1. Nice work, Dezmo, thank you!