Shape

class cgp_maya_utils.scene.Shape(name)

Bases: cgp_maya_utils.scene.DagNode

node object that manipulates any kind of shape node

count()

the count of points

Returns:the count of points
Return type:int
data(worldSpace=False)

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

Parameters:worldSpace (bool) – True : shape position is in worldSpace - False : shape position is in local
Returns:the data of the shape
Return type:dict
duplicate(newTransform=False)

duplicate the shape

Parameters:newTransform (bool) – True : duplicated shape has a new transform - False duplicate shape has the same transform
Returns:the duplicated shape
Return type:cgp_maya_utils.Shape
export(name)

export the shape in the library

Parameters:name (str) – name of the shape in the library
Returns:the exported file
Return type:cgp_generic_utils.files.JsonFile
geometryFilters(geometryFilterTypes=None, geometryFilterTypesIncluded=True)

the geometryFilters bounded to the shape

Parameters:
  • geometryFilterTypes (list[str]) – types of geometryFilters to get - All if nothing is specified
  • geometryFilterTypesIncluded (bool) – True : geometryFilter types are included - False : geometryFilter types are excluded
Returns:

the geometryFilters bound to the shape

Return type:

list[cgp_maya_utils.scene.GeometryFilter]

classmethod import_(style, parent=None, name=None)

import a shape

Parameters:
  • style (str) – style of the shape to import that exists in the shape library - ex : cube - circle
  • parent (str or cgp_maya_utils.scene.Transform) – transform to which the shape will be parented - new transform if nothing specified
  • name (str) – name of the shape
Returns:

the imported shape

Return type:

cgp_maya_utils.scene.Shape

isDeformed()

check if the shape is deformed

Returns:True : the shape is deformed - False : the shape is not deformed
Return type:bool
match(targetShape, worldSpace=False)

match the shape to the target shape

Parameters:
  • targetShape (str or cgp_maya_utils.scene.Shape) – shape to match the current shape to
  • worldSpace (bool) – True : match is in worldSpace - False : match is in local
mirror(mirrorPlane=None, worldSpace=False)

mirror the shape

Parameters:
  • mirrorPlane (str) – plane used to perform the mirror - default is cgp_generic_utils.constants.MirrorPlane.YZ
  • worldSpace (bool) – True : mirror is in worldSpace - False : mirror is in local
mirroredPositions(mirrorPlane=None, worldSpace=False)

the mirror positions of the points of the shape

Parameters:
  • mirrorPlane (str) – plane used to perform the mirror - default is cgp_generic_utils.constants.MirrorPlane.YZ
  • worldSpace (bool) – True : positions are worldSpace - False : positions are local
Returns:

the mirrored positions of the points

Return type:

list[list[float]]

points()

the points of the shape

Returns:the points of the shape
Return type:list[str]
positions(worldSpace=False)

the positions of the points of the shape

Parameters:worldSpace (bool) – True : positions are worldSpace - False : positions are local
Returns:the positions of the points
Return type:list[list[float]]
rotate(values, worldSpace=False, aroundBoundingBoxCenter=False)

rotate the shape

Parameters:
  • values (list[int, float]) – values used to rotate the shape
  • worldSpace (bool) – True : rotation is in worldSpace - False : rotation is in local
  • aroundBoundingBoxCenter (bool) – True : rotation around bounding box center - False : rotation around objet pivot
scale(values, aroundBoundingBoxCenter=False)

scale the shape

Parameters:
  • values (list[int, float]) – values used to scale the shape
  • aroundBoundingBoxCenter (bool) – If False shape will rotate around obj pivot. Otherwise around boundingBox center
setColor(color=None)

set the color of the shape

Parameters:color (int or list[int]) – color channel values to set to the shape - indexValue or [r, g, b]
setPositions(positions, worldSpace=False)

set the positions of the points of the shape

Parameters:
  • positions (list[list[int, float]]) – positions to set - [[x1, y1, z1], [x2, y2, z2], ...] - len(positions) = self.count()
  • worldSpace (bool) – True : positions are set in worldSpace - False : positions are set in local
setTransform(transform, worldSpace=False, deleteOriginalTransform=False)

set the transform of the shape

Parameters:
  • transform (str or cgp_maya_utils.scene.Transform) – transform the shape will be parented to
  • worldSpace (bool) – True : parenting occurs in worldSpace - False : parenting occurs in local
  • deleteOriginalTransform (bool) – True : original transform is deleted - False : original transform remains
transform()

the transform of the shape

Returns:the transform of the shape
Return type:cgp_maya_utils.scene.Transform or cgp_maya_utils.scene.Joint
translate(values, worldSpace=False)

translate the shape

Parameters:
  • values (list[int, float]) – values used to translate the shape
  • worldSpace (bool) – True : translation is in worldSpace - False : translation is in local