--
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/5c5853a4-ec08-40fa-bfea-2bb39ee333d5n%40googlegroups.com.
# this works fine BUT 1 obj x time
import maya.cmds as mc
LocList = []
userSel = []
len(userSel)
sel = []
sel = mc.ls(sl=1)
userSel.append(sel)
if len(sel) != 0:
_has_trans = mc.getAttr (sel[0]+'.translate', settable=True)
_has_rot = mc.getAttr (sel[0]+'.rotate', settable=True)
else :
mc.warning('Please make a selection')
# check if there is rotations
# create a loc for ech selected obj and constraint to it
if _has_rot ==1 and _has_trans ==1:
for obj in sel:
newLoc = mc.spaceLocator()
newCon = mc.parentConstraint(obj, newLoc, mo=0)
LocList.append(newLoc)
elif _has_rot ==0 and _has_trans ==1:
for obj in sel:
newLoc = mc.spaceLocator()
newCon = mc.parentConstraint(obj, newLoc, mo=0, sr=['x', 'y', 'z'])
LocList.append(newLoc)
elif _has_rot ==1 and _has_trans ==0:
for obj in sel:
newLoc = mc.spaceLocator()
newCon = mc.parentConstraint(obj, newLoc, mo=0, st=['x', 'y', 'z'])
LocList.append(newLoc)
# select all new Loc
if len(sel) != 0:
for loc in LocList:
mc.select (loc, add=1)
start = mc.playbackOptions(q=True, min=True)
end = mc.playbackOptions(q=True, max=True)
mc.bakeResults(sm=1, sr=1, t=(start, end))
#else:
#mc.warning('Please make a selection')
for loc in LocList:
mc.select (loc, add=1)
mc.delete(cn=1)
# reverse connection
if _has_rot ==1 and _has_trans ==1:
for idx, item in enumerate(LocList):
ctl = item
makeParentCons = mc.parentConstraint(ctl, userSel[0][idx], mo=True, w=1)
elif _has_rot ==0 and _has_trans ==1:
for idx, item in enumerate(LocList):
ctl = item
makeParentCons = mc.parentConstraint(ctl, userSel[0][idx], mo=True, w=1, sr=['x', 'y', 'z'])
elif _has_rot ==1 and _has_trans ==0:
for idx, item in enumerate(LocList):
ctl = item
makeParentCons = mc.parentConstraint(ctl, userSel[0][idx], mo=True, w=1, st=['x', 'y', 'z'])
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/4a3f2b41-209c-4868-a257-640db3a3bb41n%40googlegroups.com.
Justin I ddnt notice that you rewrote my script! it is so ..beautifull that way! thanks, a lot to learn from it!
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/5769299b-0b56-4238-95e9-7cdf79c37733n%40googlegroups.com.