Hey guys, so here is my problem:
I'm trying to create a code that creates an offset group with a NURBS control for joint structures. The offsetgroup needs to have the same pivot point and XYZ transformations as the selected joint.
Problem is, however, the group doesn't seem to want to centre it's pivot point to the joint and instead sets itself to the corner of the NURBS control (see the photo). What I need to know is how to set the offset group so that it's pivot is centered then the same as the joint? Any ideas guys?
Here is the code I'm currently using:
import maya.cmds as base
def cubeCtrl():
selection = base.ls(sl=True)
selectionindex = selection[0]
offsetGroup = base.group(em=True, n=str(selectionindex)+"_Offset_Group")
base.parent(offsetGroup, selection)
groupselection = base.ls(sl=True)
base.makeIdentity(r=True, t=True)
newCtrl = base.curve( d=1, p=[(0, 0, 0), (0, 0, 2), (2, 0, 2), (2, 0, 0), (0, 0, 0), (0, 2, 0), (0, 2, 2), (2, 2, 2), (2, 2, 0), (0, 2, 0), (2, 2, 0), (2, 0, 0), (2, 0, 2), (2, 2, 2), (0, 2, 2), (0, 0, 2)] )
base.xform(cp=True)
base.parent(newCtrl, offsetGroup)
base.makeIdentity(t=True, r=True)
base.xform(newCtrl, cp=True)
base.parent(groupselection, world=True)
Solved! Go to Solution.
Hey guys, so here is my problem:
I'm trying to create a code that creates an offset group with a NURBS control for joint structures. The offsetgroup needs to have the same pivot point and XYZ transformations as the selected joint.
Problem is, however, the group doesn't seem to want to centre it's pivot point to the joint and instead sets itself to the corner of the NURBS control (see the photo). What I need to know is how to set the offset group so that it's pivot is centered then the same as the joint? Any ideas guys?
Here is the code I'm currently using:
import maya.cmds as base
def cubeCtrl():
selection = base.ls(sl=True)
selectionindex = selection[0]
offsetGroup = base.group(em=True, n=str(selectionindex)+"_Offset_Group")
base.parent(offsetGroup, selection)
groupselection = base.ls(sl=True)
base.makeIdentity(r=True, t=True)
newCtrl = base.curve( d=1, p=[(0, 0, 0), (0, 0, 2), (2, 0, 2), (2, 0, 0), (0, 0, 0), (0, 2, 0), (0, 2, 2), (2, 2, 2), (2, 2, 0), (0, 2, 0), (2, 2, 0), (2, 0, 0), (2, 0, 2), (2, 2, 2), (0, 2, 2), (0, 0, 2)] )
base.xform(cp=True)
base.parent(newCtrl, offsetGroup)
base.makeIdentity(t=True, r=True)
base.xform(newCtrl, cp=True)
base.parent(groupselection, world=True)
Solved! Go to Solution.
Solved by mcw0. Go to Solution.
Might I suggest the following:
1. Create your control curve.
2. Group the control curve to itself and name it your offset group
3. Delete a parent constraint of your offset group to your joint.
Might I suggest the following:
1. Create your control curve.
2. Group the control curve to itself and name it your offset group
3. Delete a parent constraint of your offset group to your joint.
A bit of tweaking but that seems to have done the trick. Added a matchTransform instruction and it's worked 🙂 thanks!
A bit of tweaking but that seems to have done the trick. Added a matchTransform instruction and it's worked 🙂 thanks!
Can't find what you're looking for? Ask the community or share your knowledge.