Element Listing Renaming – #13 by dezmo – SketchUp


Thanks!

I assume it’s as a result of SU by some means maintain the interior reference of definition of the elements.
Maybe you may minimize (as an alternative of copy) then purge the part definition out out of your unique file then you may insert the elements with modified componetinstances with new definition names.

OR

I modified the code snippet.

If there isn’t any choice will work as earlier than.

If there’s a choice and incorporates componentinstance(s) it is going to exchange the string in definition names of chosen componentinstance(s).

If the choice doesn’t incorporates componentinstance(s), will do nothing.

def replace_in_selected_or_all_comp_defname
  mod = Sketchup.active_model
  sel = mod.choice
  if sel.empty?
    defins = mod.definitions
  else
    defins = sel.grep(Sketchup::ComponentInstance).map(&:definition).uniq
    return "No part chosen" if defins == []
  finish
  prompts = ["original string:", "new string:"]
  defaults = ["", ""]
  enter = UI.inputbox(prompts, defaults, "Change part definition title ")
  return except enter
  outdated,new = enter
  mod.start_operation("Change definition names", true)
  i = 0
  defins.everydefin
  mod.commit_operation
  "#{i} modifications"
finish
replace_in_selected_or_all_comp_defname

As regular: No warranties. Use your personal danger!



Source link

We will be happy to hear your thoughts

Leave a reply

Furniture Design Idea
Logo