View Full Version : Setting the pivot
nottoshabi 06-02-2011, 11:07 PM I created an object and I want to set its pivot to a specific obj. Having a little trouble with the command. So this is what I got so far.
cmds.ctxEditMode('obj1')
cmds.snapMode ( 'ob2', 'obj1', query=True, curve=True)
I got this stright from the docs. And I'm totally missing something. It does not give me an error, it just wont snap to obj2 center.
I dont think the snapMode command is what I'm supposed to be using.
|
|
nottoshabi
06-07-2011, 08:51 PM
Ok really? No one knows how to set the pivot throw python?
Koochy
06-07-2011, 09:27 PM
I was trying to figure this out yesterday and got this far:
from pymel.core import *
list = ls(sl=1)
x = xform(list[0], q=1, ws=1, rp=1)
for item in list:
if item != list[0]:
setAttr(item + ".rotatePivotX", x[0])
setAttr(item + ".rotatePivotY", x[1])
setAttr(item + ".rotatePivotZ", x[2])
setAttr(item + ".scalePivotX", x[0])
setAttr(item + ".scalePivotY", x[1])
setAttr(item + ".scalePivotZ", x[2])
It's a bit messy, but it works for me. Select two objects and exec script. The second object's pivot (trans, rot, scale) is then snapped to the first selected objects pivot... kind of. If the first objects pivot is not centered then it doesn't work 100%, but hey, I'm planning on fixing that stuff today (I'm still learning too).
Hope that helps.
nottoshabi
06-08-2011, 12:13 AM
Sweet. l will give that a try.
pritishd
06-08-2011, 12:24 AM
I was trying to figure this out yesterday and got this far:
from pymel.core import *
list = ls(sl=1)
x = xform(list[0], q=1, ws=1, rp=1)
for item in list:
if item != list[0]:
setAttr(item + ".rotatePivotX", x[0])
setAttr(item + ".rotatePivotY", x[1])
setAttr(item + ".rotatePivotZ", x[2])
setAttr(item + ".scalePivotX", x[0])
setAttr(item + ".scalePivotY", x[1])
setAttr(item + ".scalePivotZ", x[2])
It's a bit messy, but it works for me. Select two objects and exec script. The second object's pivot (trans, rot, scale) is then snapped to the first selected objects pivot... kind of. If the first objects pivot is not centered then it doesn't work 100%, but hey, I'm planning on fixing that stuff today (I'm still learning too).
Hope that helps.
I have a similar question. How do I align the local rotation axis of the two objects. Cause right now I set a translateZ of 5, it seems to go in opposite direction.
nottoshabi
06-14-2011, 07:39 PM
Wow that seems like a lot of work just to set a pivot. There has to be a way to query the position of an object and then tell the other objec to set its pivot in that position in space.
nottoshabi
06-16-2011, 05:56 PM
Ok so I had some head way yesturday I'm able to get the position of the pivot but then when I try to snap to it I get an error. So this is what I got so far.
parentPos = cmds.xform ('parentJnt', q=True, rotatePivot=True, worldSpace=True)
cmds.move ('childJnt', parentJnt, relative=True, objectSpace=True, worldSpaceDistance=True )
Apperentlly I can not stick in a string where a int supposed to be. I forgot the conversion code so back to digging throw the docs.
Ok so I got it to work. I used the move command but I got the coordinates manually which will work for now but not a permanent thing. If the rig changes I will need to get the coordinates manually again which definably sucks. Whats holding me back is being able to use the variable instead of the manuall coordinates.
cmds.move (0.0877452, 31.345252, 8.075083, 'childJnt.scalePivot', 'childJnt.rotatePivot')
CGTalk Moderation
06-16-2011, 05:56 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2013, Jelsoft Enterprises Ltd.