Python pymel.core.orientConstraint() Examples
The following are 11
code examples of pymel.core.orientConstraint().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
pymel.core
, or try the search function
.
Example #1
Source File: constraintTracker.py From fossil with BSD 3-Clause "New" or "Revised" License | 6 votes |
def update(self): sel = selected(type='transform') if sel: obj = sel[0] else: return self.orient.removeAll() for obj in orientConstraint(obj, q=True, tl=True): self.orient.append(obj) self.point.removeAll() for obj in pointConstraint(obj, q=True, tl=True): self.point.append(obj) self.parent.removeAll() for obj in parentConstraint(obj, q=True, tl=True): self.parent.append(obj)
Example #2
Source File: constraints.py From fossil with BSD 3-Clause "New" or "Revised" License | 6 votes |
def getOrientConstrainee(target): # type: (PyNode) -> PyNode ''' Given a target used in an orientConstraint, find the object that is orient constrained to it. ''' try: #target.parentMatrix[0].listConnections( type='orientConstraint', d=True )[0].constraintRotateZ.listConnections()[0] constraints = target.parentMatrix[0].listConnections( type='orientConstraint', d=True ) if not constraints: return None elif len(constraints) == 1: return constraints[0].constraintRotateZ.listConnections()[0] else: raise Exception( '{0} is the target of multiple constraints, too many results'.format( target ) ) except Exception: return None
Example #3
Source File: applyop.py From mgear_core with MIT License | 5 votes |
def oriCns(driver, driven, maintainOffset=False): """Apply orientation constraint Apply orientation constraint changing XYZ default connexions by rotate compound connexions Note: We have found an evaluation difference in the values if the connexion is compound or by axis Arguments: driver (dagNode or dagNode list): Driver object. driven (dagNode): Driven object. maintainOffset (bool): Keep the offset. Returns: pyNode: Orientation constraintn node. Example: .. code-block:: python import mgear.core.applyop as aop import pymel.core as pm sphere = pm.polySphere(n='sphereDriver') cube = pm.polyCube(n='cubeDriven') ori_cns = aop.oriCns(sphere[0], cube[0], True) """ oriCns = pm.orientConstraint(driver, driven, maintainOffset=maintainOffset) for axis in "XYZ": pm.disconnectAttr(oriCns + ".constraintRotate" + axis, driven + ".rotate" + axis) pm.connectAttr(oriCns + ".constraintRotate", driven + ".rotate", f=True) return oriCns
Example #4
Source File: limb.py From anima with MIT License | 5 votes |
def unique_spine_zero_controller(self): # Create Root Costrain Jnt Unde Hip cotrol # Duplicate zero Jnt tempConst = pm.duplicate(self.joints.zeroJoint, po=True, name=("Const_" + self.joints.zeroJoint )) rootConst_jnt = tempConst[0] pm.parent(rootConst_jnt, self.hipCtrl.drawnNode) pm.pointConstraint(rootConst_jnt, self.joints.zeroJoint) pm.orientConstraint(rootConst_jnt, self.joints.zeroJoint) pm.setAttr(rootConst_jnt.visibility, 0) self._stuff.append(rootConst_jnt)
Example #5
Source File: drawNode.py From anima with MIT License | 5 votes |
def inputOrient(self, target=None, maintainOff=None): if target is None and maintainOff is None: return self._inputOrient else: self._inputOrient = pm.orientConstraint(target, self.drawnNode, mo=maintainOff)
Example #6
Source File: drawNode.py From anima with MIT License | 5 votes |
def outputOrient(self, constrained=None, maintainOff=None): if constrained is None and maintainOff is None: return self._outputOrient else: self._outputOrient = pm.orientConstraint(constrained, self.drawnNode, mo=maintainOff)
Example #7
Source File: kinematicSwitch.py From fossil with BSD 3-Clause "New" or "Revised" License | 5 votes |
def _getSwitchPlug(obj): # WTF IS THIS?? ''' Given the object a bind joint is constrained to, return the switching plug. ''' bone = core.constraints.getOrientConstrainee(obj) constraint = orientConstraint( bone, q=True ) plugs = orientConstraint(constraint, q=True, wal=True) targets = orientConstraint(constraint, q=True, tl=True) for plug, target in zip(plugs, targets): if target == obj: switchPlug = plug.listConnections(s=True, d=False, p=True) return switchPlug
Example #8
Source File: constraints.py From fossil with BSD 3-Clause "New" or "Revised" License | 5 votes |
def orientSerialize(obj): # type: (PyNode) -> Dict return _constraintSerialize('orientConstraint', obj)
Example #9
Source File: constraints.py From fossil with BSD 3-Clause "New" or "Revised" License | 5 votes |
def orientDeserialize(obj, data): # type: (PyNode, Dict) -> None kwargs = copy.deepcopy(data) targets, reformattedKwargs = _constraintDeserialize(obj, kwargs) if 'mo' in reformattedKwargs: del reformattedKwargs['mo'] orientConstraint(targets, obj, mo=True, **reformattedKwargs)
Example #10
Source File: constraints.py From fossil with BSD 3-Clause "New" or "Revised" License | 5 votes |
def orientConst(*args, **kwargs): ''' orientConstraint wrapper that returns the controlling plug ''' return orientConstraint(*args, **kwargs).getWeightAliasList()[-1]
Example #11
Source File: rigging.py From anima with MIT License | 4 votes |
def create_ik_setup(self, solver='ikRPsolver', controller_radius=0.5): """Creates IK setup """ self.ik_handle, self.ik_end_effector = \ pm.ikHandle(sj=self.start_joint, ee=self.end_joint, solver=solver) self.ik_end_controller, shape = pm.circle( normal=(0, 1, 0), radius=controller_radius ) pm.parent(self.ik_end_controller, self.ik_end_effector) self.ik_end_controller.t.set(0, 0, 0) self.ik_end_controller.r.set(0, 0, 0) # create default scale attribute pm.addAttr(self.ik_end_controller, sn="minScale", at="float", dv=1.0, k=True) pm.addAttr(self.ik_end_controller, sn="maxScale", at="float", dv=2.0, k=True) for j in self.joints[:-1]: # do not scale the last joint self.ik_end_controller.minScale >> j.sx pm.parent(self.ik_end_controller, w=1) from anima.env.mayaEnv import auxiliary auxiliary.axial_correction_group(self.ik_end_controller) # constraint the orientation of the last joint to the controller pm.orientConstraint(self.ik_end_controller, self.joints[-1], mo=1) # create the point constraint pm.pointConstraint(self.ik_end_controller, self.ik_handle) # create pole controller self.ik_pole_controller = pm.spaceLocator(name='ikPoleController#') # place it to the extension of the pole vector pm.parent(self.ik_pole_controller, self.joints[1], r=1) pm.parent(self.ik_pole_controller, w=1) # I don't like this but it will help a lot move_amount = [0, -1, 0] if pm.xform(self.ik_pole_controller, q=1, ws=1, t=1)[0] < 0: move_amount = [0, 1, 0] pm.move(self.ik_pole_controller, move_amount, r=1, os=1, wd=1) pm.poleVectorConstraint(self.ik_pole_controller, self.ik_handle) auxiliary.axial_correction_group(self.ik_pole_controller) # group everything under the main_group self.main_group = pm.nt.Transform(name='IKLimbJointHierarchy_Grp#') pm.parent(self.ik_handle, self.main_group) pm.parent(self.ik_end_controller.getParent(), self.main_group) pm.parent(self.ik_pole_controller.getParent(), self.main_group) if self.do_stretchy: self.create_stretch_setup()