Make all selected unique script?
-
hi, iv been looking for a script to make all selected unique instead of making them all just #1 ,for sketchup to number them all. Dose anyone know of a script that can do that?
Im a content creator on IMVU and looking to make life easyer when making scenes, it requires placing an array of nodes across the scene so that you can place things on those spots, but it needs a certain naming veriation for every node (for example furniture.Floor01 furniture.Floor02 furniture.Floor.278). iv been looking for a way to just mass make uniqu and then in notepad after exporting from sketchup i could just use the find replace tool to remove the # and then presto, correctly named nodes ^_^ as without paying someone i doubt im gonna find a script that also names them right
Any help at all pointed in the right direction would be a BIG help to me and many others!!
i looked into dynamic content but after getting it to creat the nodes correctly i found that theres an issue with the 2 different naming veriations, one seems numberd perfectly where as the exporter only reads the other box (whole load of excitment while that lasted lol)
-
Do you need the names to be in any specific order, or does each component just need to have a name in that format?
If the former, could get tricky, if the latter, it should be fairly easy.
-
well the naming of them just goes
furniture.Floor01
furniture.Floor02
furniture.Floor03....
furniture.Floor12006
etc
but as for the order of which they are numberd it dont matter, only as long as they are all uniquly numberd ^^, even if the # is still there between the Floor and the number, we could just open notepad and your find replace to mass remove the # , it would be a grate help ^^
i also run a help site for people using sketchup for IMVU which has helped many people start off and this would help me and many others
for what ever reason if people are intrested my site is http://www.neo1471.c-o.in -
### 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
-
Thank you its a God send!! ill have a toy about with it before putting it on my site (if thats ok)
would you like me to link your name to any site or profile page? its just so people know who made there lives easyer!
-
OK. Just mention TIG from here...
-
@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 rubyi 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.
Advertisement