I have a field of Spot Lights and am trying to use pm.aimConstraint
to link their target to a locator (called "Light Point"). Here's the section that I'm struggling with and the error it gives me:
import pymel.core as pm
aimTarget = "Light Point"
selection = pm.ls(sl = True)
for each in selection:
pm.aimConstraint(aimTarget, each)
Error: MayaNodeError: file C:\Program Files\Autodesk\Maya2013\Python\lib\site-packages\pymel\internal\pmcmds.py line 140: #
Obviously the selection is all the Spot Lights.
Ideally I would like to do this without having to select all the lights, which I think would look something like this:
pm.aimConstraint("Light Point", "spotLight"+light)
"light" being the number of lights in the range of a for loop, converted to a string. This gets the same error.
I am still very new to python, but have used the first script before and am very confused why it won't work on anything, not even just the spotlights.