PDA

View Full Version : Generic Python script for Layout: QuickClone



Celshader
08-03-2012, 12:38 PM
I wrote this for a friend who had to place 100 lights on a bridge. All this script does is execute the command "Clone 1" to make just one clone without bringing up the dialogue that asks for the number of clones to be created. He assigned it to a hotkey and is now quickly creating and placing clones of lights and objects in Layout.



import lwsdk

__author__ = "Jennifer Hachigian"
__copyright__ = "Copyright (C) 2012 Jennifer Hachigian"
__version__ = "1.0"
__maintainer__ = "Not Me"
__email__ = "[email protected]"
__status__ = "Production"
__lwver__ = "11"

class QuickClone(lwsdk.IGeneric):
def __init__(self, context):
super(QuickClone, self).__init__()

# LWGeneric -------------------------------------------
def process(self, ga):
lwsdk.command("Clone 1")
return lwsdk.AFUNC_OK



ServerTagInfo = [
( "Python QuickClone", lwsdk.SRVTAG_USERNAME | lwsdk.LANGID_USENGLISH ),
( "QuickClone", lwsdk.SRVTAG_BUTTONNAME | lwsdk.LANGID_USENGLISH ),
( "Utilities/Python", lwsdk.SRVTAG_MENU | lwsdk.LANGID_USENGLISH )
]

ServerRecord = { lwsdk.GenericFactory("LW_QuickClone", QuickClone) : ServerTagInfo }

Feel free to use this "quick clone" script as-is or as the basis of your own macro script. :thumbsup:

BigHache
08-04-2012, 03:55 AM
Oh sweet. I've already needed this before.

Trying to get back to a point where I can concentrate on Python, stupid bills want to get paid every month, what's up with that?

jeric_synergy
09-12-2012, 02:20 PM
Grabbed. Assigned to ^c. >:^)

skarloc
09-13-2012, 01:14 PM
Ummmmm... Pardon me for my naiveity, your friend wanted 100 lights. Surely using the "normal" clone function, typing 100 into the quantity would have been quicker than hitting the shortcut for this function 100 times ? I've had to do similar, and that 's what I do (and then I move each one individually [or in groups], which is what you need to do anyway if you use this function.

I'm not knocking the function in any way (its great to see simple scripts here) - just its use...

jeric_synergy
09-13-2012, 10:33 PM
I can see workflow wise why one would want to add things one at a time. EG, If you're arranging things scattered around a street scene, cloning one by one gives you more artistic control. It's also easier to, say, place a rock, clone that rock, move it slightly, clone that NEW rock, move it over, rotate slightly, clone the NEW NEW rock, etc, than keep going back to the big blob of rocks in the middle of the scene. Lots less mouse travel. Plus, maybe groups, let's say 7 at a time share one coordinate (say Y=2) that the original didn't: by cloning one at a time you can save fiddly orientation mousing since a bunch might all be aligned with some particular Y, then another bunch at Y=3, then another bunch at Y=-1, etc.

To me the above is enough of a reason, but if you're not sure how many lights you want in the first place and you're just spotting them around (like fireflies), with one at a time you don't have any leftovers.

erikals
09-13-2012, 11:01 PM
that said i don't get why he didn't just use Luxigons :]

jeric_synergy
09-13-2012, 11:47 PM
Not that I'm the guy Jen's referring to (oy, a gig at Pixomondo, I can dream...), but:
1) Last time I tried Luxigons, they didn't work for me, and;
2) for artistic placement using VPR, QuickClone would probably be better.

You guys seem to be assuming that it was a very mechanical "I gotta put lights on this rigid grid" kinda thing, but it may well not have been. It could have been "maybe one HERE, then perhaps one HERE, no, that doesn't work, OK, here, yes that's better...."

erikals
09-14-2012, 04:58 AM
true.

did a quick Luxigons test, so far it seems to be workin...
(quick test though, tested in both 10.2 and 11.03)

skarloc
09-16-2012, 09:12 AM
It's also easier to, say, place a rock, clone that rock, move it slightly, clone that NEW rock, move it over, rotate slightly, clone the NEW NEW rock, etc, than keep going back to the big blob of rocks in the middle of the scene. Lots less mouse travel.
I'm a great user of keys. Select the object, create the 99 clones. Select the first clone. Move it. Press "down" to select the next one, move it, and so on. No need to use the mouse to select the next clone from the blob. (BTW, I'd love it in Modeler if they could make it so that you can use a key to "apply" stuff in the numeric window, such as moving).


Plus, maybe groups, let's say 7 at a time share one coordinate (say Y=2) that the original didn't: by cloning one at a time you can save fiddly orientation mousing since a bunch might all be aligned with some particular Y, then another bunch at Y=3, then another bunch at Y=-1, etc.
Yeah, I admit I've done that before as well (7x7 grid of the same this, with slight offsets... Although I used instances which sped up layout no end).


To me the above is enough of a reason, but if you're not sure how many lights you want in the first place and you're just spotting them around (like fireflies), with one at a time you don't have any leftovers.
True, true. It all depends on what you need to do exactly. If you know you need 100 exactly, and you use the down key, it's faster unless you want a trail of the same objects (in which case, one after the other, moving each one before cloning the next would be faster). Having them all higgledy-piggledy all over the place, probably not.