Delete Instance Name with Ruby




I have a question about a Ruby command. In one of my SketchUp models I have a dynamic roller conveyor. If I change the length, the number of rolls is recalculated. Now there are hundreds of rolls with instance names. If I export them to DWG there is the instance name over each roll.

Now I´m searching for a ruby command to delete all instance names from every component in the model.

I found this:
“Sketchup.active_model.definitions[“Name of component”]{|e|e.erase!}”
But it doesn’t work…

I´m new to ruby and want to know if anyone can help me :slight_smile:
If I type just “instances.each” it delete the complete component. Is the a way to say in Ruby something linke: “check each component in model, if there is an instance name -> delete it”

Hope you understand my nearly perfect English.
I uploaded a example file.

Thanks for help :slight_smile:
test.skp (266.6 KB)


I’m not sure what you want to achieve. Instead of trying to erase the name you could just set it to empty string (""). The name property cannot be removed from the instance.


Thanks for your answer.
There is the instance Name of every role like in the picture:

I only want to delete the Text for evey role or component in the whole Model. Maby there is an easy way with ruby



Sketchup.active_model.definitions[“Name of component”].instances.each{ |i| = "" }


:star_struck::hugs: tahnk you!!! worked perfectly
I think I will learn ruby the next time :smiley:


This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.