Create locator at control as a child script


Hey there,

Recently updated from Maya 2020 to 2022 and am having issues with one of my scripts (I am not the author).

I’m getting an invalid syntax error with this script:

#create locator at control as child

import maya.cmds as cmds
print curSel
if curSel:
for i in range(len(curSel)):
endLoc = cmds.spaceLocator(name=curSel[i] + “_loc”)
cmds.matchTransform(endLoc, curSel[i], pos=True, rot=True)
cmds.parent(endLoc, curSel[i], relative=False)

And I’m not really sure why, python is beyond me… but it was working perfectly before and is a script that I use countless times a day for animating.

Does anyone have any ideas what is throwing the syntax error?

Many thanks


Hi, maya 2022 updated python from version 2 to version 3.

Some syntax changed between them.

If you want to fix the script,
replace “print curSel” by “print(curSel)”

But other scripts could crash.
Here some info to switch back maya 2022 to python 2