PDA

View Full Version : python lightlink question


EightBit
10-28-2011, 11:19 PM
According to the manual, a light set can be used w/the lightlink command, but when I attempt to do that for unlinking, it fails. The code below shows the cmd I'm using and a workaround. The workaround works, so it seems the single command should work. User error or bug?
Thx.
cmds.lightlink( b=1, light='uniqueLites_set', object='myObjShape' ) #Fails, no error message ,but lites are not unlinked
cmds.select('uniqueLites_set')
lites = cmds.ls ( sl =1 )
for lite in lites:
cmds.lightlink( b=1, light = lite, object='myObjShape' ) # Works

It is my guess that in the single line command, Maya is interpreting 'uniqueLites_set' as a string.

WesHowe
10-29-2011, 02:55 AM
I have only used lightlink directly from MEL. There is a flag for sets that is documented as being 1 (true) by default. What happens on the single line version if you explicitly add sets=1 to it?

<* Wes *>

EDIT: Scratch that, Maya refuses to allow that flag except on query, in spite of the documentation clearly showing it allowable on create.

I did some more testing, and while you can make links to light sets, the lights in the set themselves are not linked. I have only ever used the equivalent of your second method before in my light linking. We were not using light sets, though, but rather had certain lights parented to a locator (so we could constrain that to a piece of geometry and have the lights follow it).

I don't know if your issue is a bug or poorly written/misunderstood documentation. But the MEL equivalent of your one-liner does not work as expected here.

<* Wes *>

Kecal
10-29-2011, 02:27 PM
Hi,
it seems that 'sets' argument can be used only in query mode. At least maya claims that.

I can only reduce your code to this:

lites = cmds.sets( 'uniqueLites_set', q=True )
cmds.lightlink( b=1, light=lites, object='myObjShape' )

you dont have to loop through lites variable

djx
10-29-2011, 02:32 PM
And if it has to be one line

cmds.lightlink( b=1, light=cmds.sets( 'uniqueLites_set', q=True ) , object='myObjShape' )

David

EightBit
10-30-2011, 07:27 AM
Thanks guys, I'm always interested in streamlining my code and I noticed a significant decrease in execution time for my 5 lites...

CGTalk Moderation
10-30-2011, 07:27 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.