Append character to component/s selection
-
You're right...Sorry...
What I use to do is add a number suffix or allow it to assign the definition numbers automatically.
-
Suggestion:
Shouldn't your convention be letters on the prefix and #N numbers on the suffix?
This way, you're sticking to Sketchup convention and making an unique component will work...
-
It's for a grass pack I have and it has grass species with the blades cut, uncut and withered
So to signify the difference in appearance the component will be suffixed with w for withered and c for cut.
[edg3d:ihg61x36]QxaupfdO8Mt4ZJE[/edg3d:ihg61x36]
-
They're looking really nice and judging from your vegetation output they should render fast.
My real question is... what is the Font type you used on the ad? I really like it!
-
I think it's Raleway. Need to check though.
-
@rich o brien said:
I need to append a character to a selection of components each with a different name.
eg - name-01 to become name-01w
this would need to happen to all the components I've selected. Anyone know of a tool that does this?
Are we talking Instance name or Definition name? If you change the definition name before making the instance unique, you change it for all instances if they are selected or not.
-
A simple one liner copy/pasted+<enter> in the Ruby Console would do this in a trice.
I assume you are wanting to rename the component-definitions rather than the instances [these can have separate names], and that you want to rename all definitions in the model [it could also be done on just those selected too see below].
Edit the x="" part to the character[s] you want to add onto the name e.g. W or -W or -something_witty...
For all definitions in the model
x="W";Sketchup.active_model.definitions.each{|d|next if d.image?||d.group?;d.name=d.name+x}
For selected definitions only...
x="W";s=[];Sketchup.active_model.selection.grep(Sketchup;;ComponentInstance).each{|i|s<<i.definition};s.uniq.each{|d|d.name=d.name+x}
You can rename instances in a similar way...
-
Are we talking Instance name or Definition name? If you change the definition name before making the instance unique, you change it for all instances if they are selected or not.[/quote]
Hi Sam,
I need a global name change so all instances inherit the suffix.
-
@rich o brien said:
@unknownuser said:
Are we talking Instance name or Definition name? If you change the definition name before making the instance unique, you change it for all instances if they are selected or not.
Hi Sam,
I need a global name change so all instances inherit the suffix.
That being the case, perhaps this will work for you
mod = Sketchup.active_model sel = mod.selection pos = "W"; whr = "Suffix" val = UI.inputbox(["Add;"," As;"],[pos,whr],[nil,"Prefix|Suffix"],"Rename Definitions") if val pos,whr = val cis =sel.grep(Sketchup;;ComponentInstance);cdn = []; cis.each{|ci| next if cdn.include?(ci.definition.name) ci.definition.name = pos + ci.definition.name if whr=="Prefix" ci.definition.name += pos if whr=="Suffix" cdn << ci.definition.name } end
-
Each definition has a unique name.
Editable in the Component Browser etc...
A definition can have one or more instances placed in the model.
If you use 'make_unique' on one [or more] of several instances, then the instance[s] gets a new definition, duplicated from the original, with its name getting an incrementing suffix auto-appended - e.g. 'widget' becomes 'widget#1'...
Any instance can also have its own individual name [set in Entity Info] - these instance-names are not directly connected to their definition's name.
Unlike definitions instance-names can be repeated and shared by several instances, and even instances of different definitions !
Advertisement