Transform

class cgp_maya_utils.scene.Transform(name)

Bases: cgp_maya_utils.scene.DagNode

node object that manipulates a transform node

constraints(constraintTypes=None, sources=True, destinations=True, constraintTypesIncluded=True)

the source constraints driving the node and the destination constraints the node drives

Parameters:
  • constraintTypes (list[str]) – types of constraints to get - All if nothing is specified
  • sources (bool) – True : source constraints are returned - False : source constraints are skipped
  • destinations (bool) – True : destination constraints returned - False : destination constraints are skipped
  • constraintTypesIncluded (bool) – True : constraint types are included - False : constraint types are excluded
Returns:

the constraints

Return type:

list[cgp_maya_utils.scene.Constraint, cgp_maya_utils.scene.AimConstraint, cgp_maya_utils.scene.OrientConstraint, cgp_maya_utils.scene.ParentConstraint, cgp_maya_utils.scene.PointConstraint, cgp_maya_utils.scene.ScaleConstraint,]

classmethod create(translate=None, rotate=None, scale=None, rotateOrder=None, parent=None, worldSpace=False, connections=None, attributeValues=None, name=None, **__)

create a transform

Parameters:
  • translate (list[int, float]) – translation values of the transform
  • rotate (list[int, float]) – rotation values of the transform
  • scale (list[int, float]) – scale values of the transform
  • rotateOrder (str) – rotateOrder of the transform - default is cgp_maya_utils.constants.rotateOrder.XYZ
  • parent (str or cgp_maya_utils.scene.DagNode) – parent of the transform
  • worldSpace (bool) – True : transform values are worldSpace - False : transform values are local
  • connections (list[tuple[str]]) – connections to set on the transform
  • attributeValues (dict) – attribute values to set on the transform
  • name (str) – name of the transform
Returns:

the created transform

Return type:

cgp_maya_utils.scene.Transform

data(worldSpace=False)

data necessary to store the transform node on disk and/or recreate it from scratch

Parameters:worldSpace (bool) – True : transform values are worldSpace - False : transform values are local
Returns:the data of the transform
Return type:dict
duplicate(withChildren=True)

duplicate the transform node

Parameters:withChildren (bool) – True : transform node is duplicated with its children - False : transform node is not duplicated with its children
Returns:the duplicated transform
Return type:cgp_maya_utils.scene.Transform
freeze(translate=True, rotate=True, scale=True, normal=False)

freeze the values of the transform

Parameters:
  • translate (bool) – True : translation values are frozen - False : translation values are not frozen
  • rotate (bool) – True : rotation values are frozen - False : rotation values are not frozen
  • scale (bool) – True : scale values are frozen - False : scale values are not frozen
  • normal (bool) – True : normal values are frozen - False : normal values are not frozen
match(targetTransform, attributes=None, worldSpace=True)

match the transform to the target transform

Parameters:
  • targetTransform (str or cgp_maya_utils.scene.Transform) – transform to match to
  • attributes (list[str]) – attributes to match - default is cgp_maya_utils.constants.Transform.GENERAL
  • worldSpace (bool) – True : match occurs in worldSpace - False : match occurs in local
mirror(mirrorPlane=None, attributes=None, worldSpace=False, mode=None)

mirror the transform

Parameters:
  • mirrorPlane (str) – plane of mirroring - default is cgp_generic_utils.constants.MirrorPlane.YZ
  • attributes (list) – transform attributes to mirror - default is cgp_maya_utils.constants.Transform.GENERAL
  • worldSpace (bool) – True : mirror occurs in worldSpace - False : mirror occurs in local
  • mode (str) – mode of mirroring - default is cgp_generic_utils.constants.MirrorMode.MIRROR
mirrorTransformValues(**kwargs)

the mirror transform values

Parameters:
  • mirrorPlane (str) – plane of mirroring - default is cgp_generic_utils.constants.MirrorPlane.YZ
  • worldSpace (bool) – True : mirror transform values are worldSpace - False : mirror transform values are local
  • rotateOrder (str) – rotateOrder to get the mirror transform values in - ! ONLY IN WORLDSPACE !
  • mode (str) – mode of mirroring - default is cgp_generic_utils.constants.MirrorMode.MIRROR
Returns:

the mirrored transforms

Return type:

dict

reset(translate=True, rotate=True, scale=True, shear=True)

reset the values of the transform to its default values

Parameters:
  • translate (bool) – True : translation values are reset - False : translation values are not reset
  • rotate (bool) – True : rotation values are reset - False : rotation values are not reset
  • scale (bool) – True : scale values are reset - False : scale values are not reset
  • shear (bool) – True : shear values are reset - False : shear values are not reset
rotate(x=None, y=None, z=None, worldSpace=False, mode=None)

rotate the transform

Parameters:
  • x (float) – value of rotateX to set
  • y (float) – value of rotateY to set
  • z (float) – value of rotateZ to set
  • worldSpace (bool) – True : rotate occurs in worldSpace - False : rotate occurs in local
  • mode (str) – cgp_generic_utils.constants.TransformMode.ABSOLUTE : value is replaced, default mode cgp_generic_utils.constants.TransformMode.RELATIVE : value is added
scale(x=None, y=None, z=None, mode=None)

scale the transform

Parameters:
  • x (float) – value of scaleX to set
  • y (float) – value of scaleY to set
  • z (float) – value of scaleZ to set
  • mode (str) – cgp_generic_utils.constants.TransformMode.ABSOLUTE : value is replaced default mode cgp_generic_utils.constants.TransformMode.RELATIVE : value is added
setTransformValues(transformValues, worldSpace=False)

set transform values

Parameters:
  • transformValues (dict) – transform values to set
  • worldSpace (bool) – True : values are set in worldSpace - False : values are set in local
shapes(shapeTypes=None, shapeTypesIncluded=True)

the shapes parented under the transform

Parameters:
  • shapeTypes (list[str]) – types of shape to get - All if nothing is specified
  • shapeTypesIncluded (bool) – True : shape types are included - False : shape types are excluded
Returns:

the shapes of the transform

Return type:

list[cgp_maya_utils.scene.Shape, cgp_maya_utils.scene.NurbsCurve, cgp_maya_utils.scene.NurbsSurface, cgp_maya_utils.scene.Mesh,]

shear(xy=None, xz=None, yz=None, mode=None)

shear the transform

Parameters:
  • xy (float) – value of shearXY to set
  • xz (float) – value of shearXZ to set
  • yz (float) – value of shearYZ to set
  • mode (str) – cgp_generic_utils.constants.TransformMode.ABSOLUTE : value is replaced, default mode - cgp_generic_utils.constants.TransformMode.RELATIVE : value is added
transformValues(worldSpace=False, rotateOrder=None)

the transform values

Parameters:
  • worldSpace (bool) – True : transform values are worldSpace - False : transform values are local
  • rotateOrder (str) – rotateOrder to get the transform values in ! ONLY IN WORLDSPACE !
Returns:

the transform values

Return type:

dict

transformationMatrix(worldSpace=False, rotateOrder=None)

the transformationMatrix of the transform

Parameters:
  • worldSpace (bool) – True : TransformationMatrix is initialized with the worldSpace transform values - False : TransformationMatrix is initialized with the local transform values
  • rotateOrder (str) – rotateOrder to get the transform values in - default is the current rotateOrder of the transform
Returns:

the transformMatrix

Return type:

cgp_generic_utils.api.TransformationMatrix

translate(x=None, y=None, z=None, worldSpace=False, mode=None)

translate the transform

Parameters:
  • x (float) – value of translateX to set
  • y (float) – value of translateX to set
  • z (float) – value of translateX to set
  • worldSpace (bool) – True : translation occurs in worldSpace - False : translation occurs in local
  • mode (str) – cgp_generic_utils.constants.TransformMode.ABSOLUTE : value is replaced, default mode - cgp_generic_utils.constants.TransformMode.RELATIVE : value is added