Adding suffix or prefix to instance name for multiple components

Please read this how to post your code properly:


We will understand better your problem, if you also include what Error message you see on Ruby Console when you are executing your code.


I assuming a syntax problem in your code: perhaps you are using quotation marks which is not the right one…

Does this work if I copy-paste it?

prefix= "WT01"
model = Sketchup.active_model
selection = model.selection
selection.each do |instance|
  instance.name = "#{prefix}_#{instance.name}"
end
2 Likes