Hi all, can someone tell me what the ruby code would look like to retrieve the Entity Info - Tag name for a group and place that name into the Instance: field?
Basically I want a loop that will go through all my model and copy the Tag name into the Instance field
hope this makes sense
As of SketchUp 2020 “Layers” were renamed to “Tags” in the UI. The API retains the use of “Layer” for compatibility and is synonymous with “Tag”.
The Model #definitions method
The DefinitionList object
The ComponentDefinition #group? method
The ComponentDefinition #instances method
The Group #make_unique method
The Layer #display_name method
The Layer #name= method
The Model #start_operation method
One possible code snippet:
model = Sketchup.active_model
group_defs = model.definitions.select(&:group?)
model.start_operation("Rename groups by Tag", true)
lname = i.layer.display_name
lname = i.layer.name
i.name = lname
thanks, dezmo, it works perfectly
is it possible to save this script so I can use it like an extension?
Put this into Plugin folder:
Restart Sketchup. You will have new menu in Extensions… “Rename groups by its Tag name”
Dezmo_rename_groups.rb (788 Bytes)
No warranties! Use on your own risk!
You are a legend, thanks dezmo.