Discussion:
[Maya-Python] set VRay rect light target position via Python
Jason Huang
2018-09-18 00:43:20 UTC
Permalink
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!
--
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_maya+***@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.
Justin Israel
2018-09-18 01:58:18 UTC
Permalink
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.
Post by Jason Huang
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!
--
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
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/7050a496-b852-46c2-85b9-32151253ce8a%40googlegroups.com
<https://groups.google.com/d/msgid/python_inside_maya/7050a496-b852-46c2-85b9-32151253ce8a%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
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_maya+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA1OMH78kXQpws7NkXhYqLXe4yuj%3D9D7pLzvuzKVmxYi2g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Jason Huang
2018-09-18 05:03:54 UTC
Permalink
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
Post by Justin Israel
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.
Post by Jason Huang
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!
--
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
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/7050a496-b852-46c2-85b9-32151253ce8a%40googlegroups.com
<https://groups.google.com/d/msgid/python_inside_maya/7050a496-b852-46c2-85b9-32151253ce8a%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
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
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA1OMH78kXQpws7NkXhYqLXe4yuj%3D9D7pLzvuzKVmxYi2g%40mail.gmail.com
<https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA1OMH78kXQpws7NkXhYqLXe4yuj%3D9D7pLzvuzKVmxYi2g%40mail.gmail.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
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_maya+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAN6e2OFC4u5d_qe1X1fa_tpsmqV9K-fbjLUbPn2-PGHWNJFvNw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Loading...