set VRay rect light target position via Python

34 views
Skip to first unread message

Jason Huang

unread,
Sep 17, 2018, 8:43:21 PM9/17/18
to Python Programming for Autodesk Maya
Hi all,

I am trying to set a VRay rect light's target at the world origin. 

I first try to modify the mel code to Python. With moving a rect light's target in the viewport, I got the code below as a starting point.
setAttr "VRayLightRectShape1.targetPos" -type double3 14.13 -108.221315 -203.228502 ;

However, when I execute this as MEL, the target isn't moving at all.
setAttr "VRayLightRectShape1.targetPos" -type double3 0.0 0.0 0.0 ;

I have also tried anyway in Python the following code.
cmds.setAttr('VRayLightRectShape1.targetPos', 0.0, 0.0, 0.0, type="double3")
There is no error but nor is the light's target moving to the world origin.

Is there a way to access a Rect light's target and set its translate or an efficient way to set a rect light pointing at the world origin or a locator?


Thanks!

Justin Israel

unread,
Sep 17, 2018, 9:58:33 PM9/17/18
to python_in...@googlegroups.com
I don't know if this is the right way or not, but what about using an aimConstraint with a locator? It seems like there are more internal operations happening when you manually move the targetPos manipulator as opposed to directly setting the attribute. But it works with an aimConstraint on a locator.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/7050a496-b852-46c2-85b9-32151253ce8a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jason Huang

unread,
Sep 18, 2018, 1:04:17 AM9/18/18
to python_in...@googlegroups.com
Hey Justin,

Thanks for the input. I did think about using aimConstraint with a locator but ran into an issue where the VRay rect light keeps rotating itself by 90-degree on some axis to point away from the locator it's constraint to.
After several attempts, I was able to get a workaround by following the steps below.
Through Python code:
1. create the rect light
2. translate it a bit on positive z. I did (0, 0, 1) via setAttr. (VRay rect light points to negative z as created)
3. do an aimConstraint with maintainOffset=True between the locator at the world origin and the rect light.

Now, the rect light will be pointing at that locator wherever the rect light is moved to.

cheers,
Jason

You received this message because you are subscribed to a topic in the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python_inside_maya/er-XRbiAK80/unsubscribe.
To unsubscribe from this group and all its topics, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA1OMH78kXQpws7NkXhYqLXe4yuj%3D9D7pLzvuzKVmxYi2g%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages