[Plugin] Make Unique (find or request)
-
Hey Ruby Guru's
Since each copy of a face-me component, especially my new 2.5D+ models when copies are rotated, need to be made unique to render correctly...and since I (and maybe other will) often forget to do that step with each copy: I'd like to find a ruby that will allow me to select all copies of a component then with one click make each copy "unique" to all others.
Is it out there...where?
If not...can some one make such?Thanks a bunch in advance, Tom.
-
Tom,
FredoScale includes a Make uniquefunction that should work on a pre-selection or by pick and choose.
It is however recursive, that is components within groups and components will also be made unique.
Fredo
-
This code snippet will 'make_unique' all selected instances.
It does not affected nested components.def makeallunique() model=Sketchup.active_model sel=model.selection sela=sel.to_a sela.each{|e| if e.class==Sketchup;;ComponentInstance and e.definition.instances[1] e.make_unique end#if } end#def
If you want to remove their 'face_me-ness' use this afterwards...
def makeallnotfaceme() model=Sketchup.active_model sel=model.selection sela=sel.to_a sela.each{|e| if e.class==Sketchup;;ComponentInstance and not e.definition.instances[1] and e.definition.behavior.always_face_camera e.definition.behavior.always_face_camera=false end#if } end#def
-
Thanks, Guys, I'll guess one or both of these would work...but I don't understand some of your terms, so I'd better explain better what I'm looking for:
My new 2.5D+ trees are non-face-me components with face-me leaf-bunch components nested within them...so you can rotate the tree (or change the view) and another side of the trunk and branches show (like a real tree, sorta). One (or several copies facing the same way) renders great:
Once a copy is rotated all the nested face-me components render as if facing the same (in relation to the "front" of the outside tree component) as the last copy...below the right copy is rotated 90deg:
...below the copy is made unique, and now both render correctly:
...below the first copy is rotated 60deg, the second an additional 60deg, so the original is rendered as if the leaf pngs are facing away from the camera:
But SU's "make unique" does not make the nested leaf-bunch components unique, only the outside tree component...an obvious advantage, to me at least: so, do either of these ruby's work as I'm hoping?
-
@tig said:
This code snippet will 'make_unique' all selected instances.
It does not affected nested components.I can't seem to make this script work (the make unique script). I'm pasting the script into the web console, selecting all the components I want to make unique, and evaluating the code. It appears that it's working, but then the names of the components remain unchanged.
-
@danbig said:
@tig said:
This code snippet will 'make_unique' all selected instances.
It does not affected nested components.I can't seem to make this script work (the make unique script). I'm pasting the script into the web console, selecting all the components I want to make unique, and evaluating the code. It appears that it's working, but then the names of the components remain unchanged.
Recopy it now!
I've corrected a typo that should have returned an error message!
It should now work... -
@tig said:
Recopy it now!
I've corrected a typo that should have returned an error message!
It should now work...Hmmm. It's still behaving the same way.
The outliner "blinks" like the script is working, but the names still remain the same.
-
Here's a similar thread where a script is posted that is working for me (TIG, I remain grateful to you for this and your many other contributions; I'm not sure why this one isn't working for me):
http://forums.sketchucation.com/viewtopic.php?f=323&t=31648&p=279496#p279496
-
Tig, your script runs OK in my system, could Tom be experiencing problems with another plugin? Anyway, can you tell me why you elected to make an array
sela=sel.to_a
ofsel = model.selection
, and then useclass.e==.....
instead ofe.is_a?
? -
@honoluludesktop said:
Tig, your script runs OK in my system, could Tom be experiencing problems with another plugin? Anyway, can you tell me why you elected to make an array
sela=sel.to_a
ofsel = model.selection
, and then useclass.e==.....
instead ofe.is_a?
?If you process a
selection
that changes [typically from an 'erase!'] [and the same withentities
] and where later you might rely on its contents to be consistent, it's a good idea to take a 'snapshot' of it with.to_a
AND usee.valid?
tests... Otherwise every time you look at the 'selection' or 'entities' it might change unexpectedly...
There are several ways of checking on the 'type' of thing you have.
The SUp methode.typename=="Edge"
is fine for testing a few things... but it's slow if there are many iterations.
Ruby native methods likee.is_a?("Edge")
ore.kind_of?("Edge")
or evene.instance_of?("Edge")
are [usually] quicker, but...
the base methode.class==Sketchup::Edge
is the base test and it is [usually] the fastest...
[you have a typo in your post, it'se.class...
NOTclass.e...
] -
Tig, thanks for the lesson. Class.e, must have been thinking about that Benz model:-)
Advertisement