Mass rename components
-
You could try editing the code as follows - inside the
{}
block of
...each{|d|...}
substitute...
Change the value ofi=
to how many characters you want to loose...
To trim off the end usei=10;n=d.name;1.times{n=n.chop};d.name=n;
To trim off the start use
i=10;n=d.name;n=n[i..-1];d.name=n;
-
@tig said:
You could try editing the code as follows - inside the
{}
block of
...each{|d|...}
substitute...
Change the value of
i=
to how many characters you want to loose...
To trim off the end use
i=10;n=d.name;1.times{n=n.chop};d.name=n;
To trim off the start use
i=10;n=d.name;n=n[i..-1];d.name=n; >
thanks for your help,much appreciated
would you please create a file for me with a calling name like
delete "last_3"
or
Delete"frist_5"
i am able to use the banding "prefix-" script
i don't know anything about coding
but your script is what i was looking for and need -
Copy/Paste this code into the Ruby Console to rename all of the model's definitions, with 3 characters off the end of their names - change i=3 to another value as desired...
m=Sketchup.active_model;m.start_operation('chop defns',true);c=0;m.definitions.each{|d|i=3;n=d.name;(1.times{n=n.chop};d.name=n;c+=1)};puts"#{c} definition-names chopped.";m.commit_operation;
Or use this code to strip 5 characters off the names' beginnings - again edit i=5 as desired...
m=Sketchup.active_model;m.start_operation('trim defns',true);c=0;m.definitions.each{|d|i=5;n=d.name;n=n[i..-1];d.name=n;c+=1)};puts"#{c} definition-names trimmed.";m.commit_operation;
Advertisement