@tig said:
### Makes all selected instances unique and edits names...
> ### Copy all of this text into a text-file called something like
> ### makeallselectedunique.rb - in the Plugins folder...
> ### type 'makeallselectedunique' in the Ruby console
> ### it works on current selection
> def makeallselectedunique()
> ints=[];Sketchup.active_model.selection.each{|e|
> if e.typename=="ComponentInstance"
> e.make_unique ### make instance unique
> ints.push(e) ### keep list of these instances
> end#if
> }#end each
> ints.each{|e|name=e.definition.name
> ### name with '#nn' on end, e.g. ABC#2
> prefix=(name.split("#")-[name.split("#").last]).to_s
> prefix=name if prefix==""
> ### e.g. ABC
> suffix=name.split("#").last.to_i ### e.g. 2 as integer
> suffix=1 if suffix<1
> ### check all extg defs for possible new name
> Sketchup.active_model.definitions.each{|d|
> suffix=suffix+1 if d.name==prefix+suffix.to_s
> ### e.g. ABC2 exists so try to make it ABC3 etc
> }
> newname=prefix+suffix.to_s
> e.definition.name=newname ### renames definition
> puts name+" >>> "+newname ### put a # in front of this line to stop console printout
> }#end each
> return nil
> end#def
Hello,
i need a similar script but i don't know ruby π
i need to edit all names but not all definitions and just add a counter after the name like this:
furniture.Floor.01,furniture.Floor.02,furniture.Floor.03,...,furniture.Floor.10,furniture.Floor.11,furniture.Floor.12,....
where name is the name of the object.
Also if there are some object like furniture.Floor.01 and furniture.Floor.02 for example the script can start to add counter from 03.
Can you edit your script with my requests please? π
I'm waiting for your reply, thank's. π