mgear.core.applyop

Apply operator module

Operators are any node that connected to other nodes creates a rig behaviour:

I.E: IK solvers and  constraints are operators
mgear.core.applyop.aimCns(obj, master, axis='xy', wupType='objectrotation', wupVector=[0, 1, 0], wupObject=None, maintainOffset=False)

Apply a direction constraint

Parameters:
  • obj (dagNode) – Constrained object.
  • master (dagNode) – Constraining Object.
  • axis (str) – Define pointing axis and upvector axis (combination of xyz and -x-y-z).
  • wupType (str) – scene, object, objectrotation, vector, or none.
  • wupVector (list of 3 float) – world up vector. Exp: [0.0,1.0,0.0].
  • wupObject (pyNode) – world up object.
  • maintainOffset (bool) – Maintain offset.
Returns:

Newly created constraint.

Return type:

pyNode

mgear.core.applyop.curvecns_op(crv, inputs=[])
mgear.core.applyop.gear_curvecns_op(crv, inputs=[])

create mGear curvecns node.

Parameters:
  • crv (nurbsCurve) – Nurbs curve.
  • inputs (List of dagNodes) – Input object to drive the curve. Should be same number as crv points. Also the order should be the same as the points
Returns:

The curvecns node.

Return type:

pyNode

mgear.core.applyop.gear_curveslide2_op(outcrv, incrv, position=0, maxstretch=1, maxsquash=1, softness=0)

Apply a sn_curveslide2_op operator

Parameters:
  • outcrv (NurbsCurve) – Out Curve.
  • incrv (NurbsCurve) – In Curve.
  • position (float) – Default position value (from 0 to 1).
  • maxstretch (float) – Default maxstretch value (from 1 to infinite).
  • maxsquash (float) – Default maxsquash value (from 0 to 1).
  • softness (float) – Default softness value (from 0 to 1).
Returns:

The newly created operator.

Return type:

pyNode

mgear.core.applyop.gear_ikfk2bone_op(out=[], root=None, eff=None, upv=None, fk0=None, fk1=None, fk2=None, lengthA=5, lengthB=3, negate=False, blend=0)

Apply a sn_ikfk2bone_op operator

Parameters:
  • out (list of dagNodes) – The constrained outputs order must be respected (BoneA, BoneB, Center, CenterN, Eff), set it to None if you don’t want one of the output.
  • root (dagNode) – Object that will act as the root of the chain.
  • eff (dagNode) – Object that will act as the eff controler of the chain.
  • upv (dagNode) – Object that will act as the up vector of the chain.
  • fk0 (dagNode) – Object that will act as the first fk controler of the chain.
  • fk1 (dagNode) – Object that will act as the second fk controler of the chain.
  • fk2 (dagNode) – Object that will act as the fk effector controler of the chain.
  • lengthA (float) – Length of first bone.
  • lengthB (float) – Length of second bone.
  • negate (bool) – Use with negative Scale.
  • blend (float) – Default blend value (0 for full ik, 1 for full fk).
Returns:

The newly created operator.

Return type:

pyNode

mgear.core.applyop.gear_intmatrix_op(mA, mB, blend=0)

create mGear interpolate Matrix node.

Parameters:
  • mA (matrix) – Input matrix A.
  • mB (matrix) – Input matrix A.
  • blend (float or connection) – Blending value.
Returns:

Newly created mGear_intMatrix node

Return type:

pyNode

mgear.core.applyop.gear_inverseRotorder_op(out_obj, in_obj)

Apply a sn_inverseRotorder_op operator

Parameters:
  • out_obj (dagNode) – Output object.
  • in_obj (dagNode) – Input object.
Returns:

The newly created operator.

Return type:

pyNode

mgear.core.applyop.gear_mulmatrix_op(mA, mB, target=False, transform='srt')

Create mGear multiply Matrix node.

Note

This node have same functionality as the default Maya matrix multiplication.

Parameters:
  • mA (matrix) – input matrix A.
  • mB (matrix) – input matrix B.
  • target (dagNode) – object target to apply the transformation
  • transform (str) – if target is True. out transform to SRT valid value s r t
Returns:

Newly created mGear_multMatrix node

Return type:

pyNode

mgear.core.applyop.gear_rollsplinekine_op(out, controlers=[], u=0.5, subdiv=10)

Apply a sn_rollsplinekine_op operator

Parameters:
  • out (dagNode) – onstrained Object.
  • controlers (list of dagNodes) – Objects that will act as controler of the bezier curve. Objects must have a parent that will be used as an input for the operator.
  • u (float) – Position of the object on the bezier curve (from 0 to 1).
  • subdiv (int) – spline subdivision precision.
Returns:

The newly created operator.

Return type:

pyNode

mgear.core.applyop.gear_spinePointAtOp(cns, startobj, endobj, blend=0.5, axis='-Z')

Apply a SpinePointAt operator

Parameters:
  • cns (Constraint) – The constraint to apply the operator on (must be a curve, path or direction constraint).
  • startobj (dagNode) – Start Reference.
  • endobj (dagNode) – End Reference.
  • blend (float) – Blend influence value from 0 to 1.
  • axis (string) – Axis direction.
Returns:

The newly created operator.

Return type:

pyNode

mgear.core.applyop.gear_spinePointAtOpWM(cns, startobj, endobj, blend=0.5, axis='-Z')

Apply a SpinePointAt operator using world matrix

Parameters:
  • Constraint (cns) – The constraint to apply the operator on (must be a curve, path or direction constraint).
  • startobj (dagNode) – Start Reference.
  • endobj (dagNode) – End Reference.
  • blend (float) – Blend influence value from 0 to 1.
  • axis (str) – Axis direction.
Returns:

The newly created operator.

Return type:

pyNode

mgear.core.applyop.gear_spring_op(in_obj, goal=False)

Apply mGear spring node.

Parameters:
  • in_obj (dagNode) – Constrained object.
  • goal (dagNode) – By default is False.
Returns:

Newly created node

Return type:

pyNode

mgear.core.applyop.gear_squashstretch2_op(out, sclref=None, length=5, axis='x', scaleComp=None)

Apply a sn_squashstretch2_op operator

Parameters:
  • out (dagNode) – Constrained object.
  • sclref (dagNode) – Global scaling reference object.
  • length (float) – Rest Length of the S&S.
  • axis (str) – ‘x’ for scale all except x axis…
  • scaleComp (list of float) – extra scale compensation to avoid double scale in some situations.
Returns:

The newly created operator.

Return type:

pyNode

mgear.core.applyop.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

Parameters:
  • driver (dagNode or dagNode list) – Driver object.
  • driven (dagNode) – Driven object.
  • maintainOffset (bool) – Keep the offset.
Returns:

Orientation constraintn node.

Return type:

pyNode

Example

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)
mgear.core.applyop.pathCns(obj, curve, cnsType=False, u=0, tangent=False)

Apply a path constraint or curve constraint.

Parameters:
  • obj (dagNode) – Constrained object.
  • curve (Nurbscurve) – Constraining Curve.
  • cnsType (int) – 0 for Path Constraint, 1 for Curve Constraint (Parametric).
  • u (float) – Position of the object on the curve (from 0 to 100 for path constraint, from 0 to 1 for Curve cns).
  • tangent (bool) – Keep tangent orientation option.
Returns:

The newly created constraint.

Return type:

pyNode

mgear.core.applyop.splineIK(name, chn, parent=None, cParent=None, curve=None)

Apply a splineIK solver to a chain.

Parameters:
  • name (str) – Name of the operator node.
  • chn (list of joints) – List of joints. At less 2 joints should be in the list.
  • parent (dagNode) – Parent for the ikHandle.
  • cParent (dagNode) – Parent for the curve.
  • curve (dagNode) – Specifies the curve to be used by the ikSplineHandle. This param is optional.
Returns:

ikHandle node and splinecrv in a list

Return type:

list

Example

>>> aop.splineIK(self.getName("rollRef"),
                 self.rollRef,
                 parent=self.root,
                 cParent=self.bone0 )