Create locators at geo pivot(from arrays)


#1

Hi everybody,
i’m working on a script to create locators on some instances to parent them on follicles.
The script is very basic, i have some problem inheriting the rotation, and also in general on non freezed object.
Second problem is that i need all locators created in the loop to be in a list, so that i can parent them to the surface and the instance.
Some hints on how to do would be great!!Thanks alot!

`
#CREATE FEW SPHERE AND RUN IT!
import maya.cmds as cmds

curSel = cmds.ls(long = True, selection = True,)
k=0
x=0
y=0
z=0
for items in curSel:

geo=curSel[k]
a=cmds.getAttr (geo+’.scalePivot’)
x=cmds.getAttr (geo+’.scalePivotX’)
y=cmds.getAttr (geo+’.scalePivotY’)
z=cmds.getAttr (geo+’.scalePivotZ’)
rx=cmds.getAttr (geo+’.rx’)
ry=cmds.getAttr (geo+’.ry’)
rz=cmds.getAttr (geo+’.rz’)

locator=cmds.spaceLocator(p=[x,y,z])
locatorsList=[]
locatorsList.append(locator)
locPiv = [x, y, z]
cmds.xform(locator[0], piv=locPiv, os=True)

k=k+1

print locatorsList`


#2

Got the error about the list population,i declare the locatorsList empty at every loop, so i did declared it outside the loop…
Now i miss the right rotation…if try the script on a freezed transform and rotation object is ok…otherwise there is an offset…

import maya.cmds as cmds

curSel = cmds.ls(long = True, selection = True,)
k=0
x=0
y=0
z=0
locatorsList=[]
for items in curSel:

geo=curSel[k]
a=cmds.getAttr (geo+’.scalePivot’)
x=cmds.getAttr (geo+’.scalePivotX’)
y=cmds.getAttr (geo+’.scalePivotY’)
z=cmds.getAttr (geo+’.scalePivotZ’)
rx=cmds.getAttr (geo+’.rx’)
ry=cmds.getAttr (geo+’.ry’)
rz=cmds.getAttr (geo+’.rz’)

locator=cmds.spaceLocator(p=[x,y,z])
locatorsList.append(locator)

cmds.setAttr(locator[0]+’.rx’,rx)
cmds.setAttr(locator[0]+’.ry’,ry)
cmds.setAttr(locator[0]+’.rz’,rz)

locPiv = [x, y, z]
cmds.xform(locator[0], piv=locPiv, os=True)

k=k+1

print locatorsList