Note:
SketchUp (therefore, Ruby API either) does not keep track about the changes of the scenes or its properties. Therefore the text replacement what this snippet do, cannot be undone. (Ctrl+z, Alt+Backspace, undo button wont work.)
However using the opposite find-replace string pair can be appropriate.
I told you! Don’t be lazy to make a backup(s)!
Copy paste the code below to Ruby console and hit Enter. You will have a menu in Extension>“Find-Replace in Scene names”
Enter what you want to Find and Replace to into the popup.
All occurrences of the “Find:” string will be replaced to a “Replace to:” string in all scene names.
Does not really tested…
No warranties! Use at your own risk!
module Dezmo::FindReplaceinPageNames
extend self
def run
prompt = ["Find:", "Replace to:"]
defaults = ["", "" ]
input = UI.inputbox(prompt, defaults, "Find&Replace in Scene names")
return unless input
rename_pages(*input)
end
def rename_pages(find, replace)
model = Sketchup.active_model
pages = model.pages
model.start_operation("Find&Replace in Scene names", true)
pages.each do |page|
page.name = page.name.gsub(find, replace)
end
model.commit_operation
end
unless defined?(@ui_loaded)
UI.menu("Plugins").add_item("Find-Replace in Scene names") { run }
@ui_loaded = true
end
end
You can also install it with Extension Manager, if it works…and you like it.
Dezmo_find-replace_in_pagenames.rbz (501 Bytes)