Is there a plugin to batch rename scenes?
-
I have a SU model with dozens of scenes that I'd like to batch rename, in this case by replacing the "Scene" prefix (with a one or two letter appellation) and adding a sequential suffix from the current order.
Is anyone aware of a plugin with that function β maybe one of Renderiza's?
If not, would it be difficult/possible to write one?
Thanks,
Doug
-
n=inputbox(["Prefix; "],["N"],"Scene_Rename");Sketchup.active_model.pages.each_with_index{|p,i|p.name="#{n[0]} #{i+1}"}if n;puts
Copy+paste+enter this Ruby one-liner into the Ruby Console - it renames all scene-tabs in order with the 'Prefix' - e.g. 'N 1', 'N 2' etc...
The dialog lets you type in any desired 'Prefix'... -
Thanks again TIG
-
Thanks TIG.
When I had time last night I went back to look at Rederiza's ReScene and it does have a rename function.
It's very slow to load though (at least on a Mac), so your one-liner will be useful.Is there a (simple) way to modify it to rename only selected scenes?
-
@tig said:
n=inputbox(["Prefix; "],["N"],"Scene_Rename");Sketchup.active_model.pages.each_with_index{|p,i|p.name="#{n[0]} #{i+1}"}if n;puts
Copy+paste+enter this Ruby one-liner into the Ruby Console - it renames all scene-tabs in order with the 'Prefix' - e.g. 'N 1', 'N 2' etc...
The dialog lets you type in any desired 'Prefix'...Hi TIG, Many thanks for this code. Is there anyway of adding some code to this that will allow you to select the scenes to rename?
Ludolff
-
You can only select scenes that have names matching a pattern...
Let's say you want to rename only prefixed scenes containing the text 'Plan', you need to enter an extra option...n = inputbox( ["Prefix; ", "Pattern; "], ["N", "Plan"], "Scene_Rename" ); Sketchup.active_model.pages.each_with_index{|p, i| (p.name = "#{n[0]} #{i+1}") if p.name =~ /#{n[1]}/ } if n; puts
BUT you need to decide on the 'pattern' !
-
Thank you a lot TIG, you save my day !!!
-
Thank you TIG! Is there a way to rename using filter/ conditions? Example I have time scene names, like Scene 1 10:00am, Scene 2 1:00pm, Scene 3 6:00pm, (etc.. lots of it)
I want to rename all time to use 24-hour military time convention. Is it possible? So all with "10:00am" becomes-> 1000. Same goes with others.Thanks!
-
You need to add some extra code, e.g.
read the scene name
then split it at the space etc etcname="Scene 2 1;00pm" splitname=name.split(" ") ###>>> ["Scene", "2", "1;00pm"] timestring = splitname[2] ###>>> "1;00pm" ###delete the ; timestring.gsub!(/[;]/, "") ###>>> "100pm" ###now check if pm if timestring=~/pm$/ timestring.gsub!(/pm$/, "") time_num=timestring.to_i + 1200 ###>>> 100 >>> 1300 timestring=time_num.to_s ### elsif timestring=~/am$/ timestring.gsub!(/am$/, "") ###>>> 100 end name=splitname[0]+" "+splitname[1]+" "+timestring ### modify name >>> "Scene 2 1300" ### ### now rename that scene with the modified name etc... ###
To strip off the entire 'Scene N ' part just use:
name=timestring ### modify name >>> "Scene 2 1;00pm" >>> "1300"
Advertisement