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.
Yes, this looks like it might do the trick. Mike the SketchUp Sage already sent me the link. Coding is a little over my head. It’d be like learning Arabic or Klingon. I got a syntax error, after ‘copy and paste’ so obviously did something wrong. I’ll figure it out. Thank you Learned One.
This is amazing!
I’m drawing up a library of elements in order to use Quantifier Pro.
However, sometimes I only need to change the name of some of the components with partly the same name.
For example, I have 100 components with name ‘AA_L_x_y_z’ with x/y/z being variables.
I want to change 50 of them to ‘AA_P_x_y_z’. If I were to use this method in the same model, all 100 of them would change. So I copy the 50 ones I want to rename to a blank model, change the name, and then copy them back in the master model. The problem here is that the name changes back to the original name.
Any remedy for this would be very welcome.
I guess it is because SU somehow keep the internal reference of definition of the components.
Perhaps you can cut (instead of copy) then purge the component definition out from your original file then you can insert the components with modified componetinstances with new definition names.
I modified the code snippet.
If there is no selection will work as before.
If there is a selection and contains componentinstance(s) it will replace the string in definition names of selected componentinstance(s).
If the selection does not contains componentinstance(s), will do nothing.
mod = Sketchup.active_model
sel = mod.selection
defins = mod.definitions
defins = sel.grep(Sketchup::ComponentInstance).map(&:definition).uniq
return "No component selected" if defins == 
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
next unless defin.name.include?(old)
defin.name = defin.name.sub(old,new)
i += 1
I have some simillar problem I am trying to solve but it’s more focused on profile builder.
I have created some moldings with profile builder and I use the “generate as components” feature because I need to extract a cut list at the end with OCL.
My issue is that profile builder adds auto names for the generated components so the definition is something like “Group#”. It does add the profile name in the instance field but this does not help me. I am looking for a way to make profile builder create componenets using the profile name as the definition. Looking for a workaround is the reason I got to this thread, so this could be a workaround to have a script that can change the instance names.
Mike, I do ALL with OCL for woodworking, I still miss a couple of things (posibility of adding veneer similar to the edge banding beeing one of them) but it is the best tool so far.
I do have Quantifier Pro, bought it with PB3 as a bundle but for the life of me I can’t figure out how to use it, specifically in my workflow. I was planing to ask for help from Dale and his team.
If you are curios I can upload a model I’m working on and give you a quick tour of my workflow. maybe some of you guys can give me some improvement ideas.
So what you have there is the model, and then I added the 2 pdfs that we print for production, the printed versions will be distributed in the factory in the specific area, solid wood sheet to the team that prepares the wood pieces, panels sheet to the panel cutting area and the subasembly sheet to the assembly team.
The thing I lose time with (not taking in to account layout in the past, the 2022 version is, so far, brilliantly smooth and fast) is making the bill of materials the way we need it, I have to export multiple csv files that I then import back in google sheet and then I have to make a lot of manual adjustments. Thats why I need some extra functionality in Open Cut List, hopfully the guys will make time for this in the future.
Mike, I don’t need and use the cutting diagram, if you take a look at the first pdf with the list of parts (the BOM) that is the reason I use OCL, you think I can do that with Quantifier Pro?
I tried a couple of times but didn’t get it, I don’t know how to use it yet.