Is this something what you are looking for?
Copy-paste the code below to Ruby console and hit Enter (Return)
Type the string what you want to replace and for what…
the first occurrence of string will be replaced in all definition names in a model
(You can undo it)
See animation (Click on it if not animating)
NOTE: I don’t think it’s going to go wrong, but it’s best to try a “non-live” model or have a backup.
def replace_in_comp_defname
mod = Sketchup.active_model
defins = mod.definitions
prompts = ["original string:", "new string:"]
defaults = ["", ""]
input = UI.inputbox(prompts, defaults, "Change component definition name ")
return unless input
old,new = input
mod.start_operation("Change definition names", true)
i = 0
defins.each{|defin|
next unless defin.name.include?(old)
defin.name = defin.name.sub(old,new)
i += 1
}
mod.commit_operation
"#{i} changes"
end
replace_in_comp_defname