Modeling

Components

Also see cmds.objutils.selection for various functions

normalListFromVtxFaces(vtxFaceList)
softFromEdge(edge)

From an edge determine if its soft or hard from the vert normals

Parameters:

edge (str) – A maya edge selection eg. “pSphere1.e[101]”

Return soft:

True if soft False if hard

Rtype soft:

bool

softEdgeList(obj, time=False)

For each edge in a polygon object check if it’s hard or soft and return as a list

NOTE: Unused as is too slow, now using zoo.libs.buliarcacristian.lockNormals_toHS

Annoying function to work around not being able to set vertexNormals without locking them.

WARNING: This takes a lot of time on dense meshes 20sec per 3k faces. Slow function

Parameters:

obj (str) – A maya Mesh object transform node

Return edgeList:

A list of edges of the object [“pSphere1.e[60:61]” “pSphere1.e[63:66]”]

Rtype edgeList:

list(str)

Return softList:

A list of soft edges True/False will match the edgeList [True, False]

Rtype softList:

list(bool)

selectFacesComponentMode(faces)

Selects faces while in component mode

tris(meshList, select=True, message=True)

From a list of mesh shapes return the triangle faces

Parameters:
  • meshList (list(str)) – A list of mesh shapes

  • select (list(str)) – Select the faces?

  • message (bool) – Report a message to the user?

Return tris:

A list of selected faces

Rtype tris:

list(str)

ngons(meshList, select=True, message=True)

From a list of mesh shapes return the triangle faces

Parameters:
  • meshList (list(str)) – A list of mesh shapes

  • select (list(str)) – Select the faces?

  • message (bool) – Report a message to the user?

Return ngons:

A list of selected faces

Rtype ngons:

list(str)

selectedMeshes(message=True)

Returns mesh nodes from the current selection

Parameters:

message (bool) – Report a message to the user?

Return meshList:

A list of mesh nodes

Rtype meshList:

list(str)

ngonsFromSelection(select=True, message=True)

From the current selection return or select all the ngon faces

Parameters:
  • select (list(str)) – Select the faces?

  • message (bool) – Report a message to the user?

Return ngons:

A list of selected faces

Rtype ngons:

list(str)

trisFromSelection(select=True, message=True)

From the current selection return or select all the tri faces

Parameters:
  • select (list(str)) – Select the faces?

  • message (bool) – Report a message to the user?

Return tris:

A list of selected faces

Rtype tris:

list(str)

Create

from zoo.libs.maya.cmds.modeling import create create.createPrimitiveAndMatch(primitive=”cube”)

createPrimitiveAndMatch(primitive='cube')

Creates an object and matches it to the currently selected object.

Creates one object at a time. Objects are:

“cube”, “sphere”, “cylinder”, “plane”, “nurbsCircle”, “torus”, “cone”, “pyramid”, “pipe”, “helix”, “gear”, “soccerall”, “svg”, “superEllipsoid”, “sphericalHarmonics”, “ultraShape”, “disk”, “platonicSolid”

Parameters:

primitive (str) – the name of the primitive to build

Return newObj:

The name of the new object created

Return type:

str

createPrimitiveAndMatchMultiSel(primitive='cube', parent=False)

Creates objects and matches to every selected object. Will create many objects if many are selected.

Objects are:

“cube”, “sphere”, “cylinder”, “plane”, “nurbsCircle”, “torus”, “cone”, “pyramid”, “pipe”, “helix”, “gear”, “soccerall”, “svg”, “superEllipsoid”, “sphericalHarmonics”, “ultraShape”, “disk”, “platonicSolid”

Parameters:
  • primitive (str) – the name of the primitive to build

  • primitive – parent objects together?

Return newObjs:

A list of all the new objects created

Return type:

str

createZBrushGridPlaneSize()

Creates a polygon plane the size of the ZBrush grid. Used for sending objects to Zbrush

Edges

getObjEdgeCount()

Gets the edge count of selected objs and returns two lists

Return objList:

list of object names

Rtype objList:

list

Return edgeList:

list of edge numbers that correspond to the objList names

Rtype edgeList:

list

randomizeFlipTriEdge(objList, edgeList, selectObjs=True, randomizeEvery=5)

Flips random triangle edges give an object and corresponding edge list On medium to high poly counts can be slow

Return objList:

list of object names

Rtype objList:

list

Return edgeList:

list of edge numbers that correspond to the objList names

Rtype edgeList:

list

Parameters:
  • selectObjs (bool) – would you like to select all object after completion

  • randomizeEvery (int) – best not to randomize every triangle, so will randomize 1 in x

randomizeFlipTriEdgeSel(triangulate=True)

Flips random triangle edges on selected objects, optionally triangulates the meshes too On medium to high poly counts will be slow

Parameters:

triangulate (bool) – Would you like to triangulate all meshes

Extrude

meshObjs(objList)

Filters only meshes

Parameters:

objList (list(str)) – list of objects

Return meshList:

list of meshes

Rtype meshList:

list(str)

meshObjsSelected()

Returns meshes that are selected

Return meshList:

list of meshes

Rtype meshList:

list(str)

extrudeCenterThickness(obj, thickness=1.0, weight=0.5, select=True)

Extrudes a flat object to be thick so that the extrude affects both sides, making it thicker on both sides. Or as per the weight value. 0.5 is centered, 1 extrudes down, zero extrudes up.

Also supports object lists so long as faces or mesh objects.

Parameters:
  • obj (list(str)) – The name of the object or face list to extrude

  • thickness (float) – The thickness of the object in Maya units usually cms

  • weight (float) – Controls the direction of the extrude, 0.5 is center and the extrude will go out each side

  • select (bool) – Select the original selection after the extrude completes?

Return extrudeNode:

The name of the extrudeNode that was created

Rtype extrudeNode:

str

Return moveVertNode:

The name of the extrudeNode that was created

Rtype moveVertNode:

str

extrudeCenterThicknessSelected(thickness=1.0, weight=0.5, select=True, message=True)

Extrudes selected flat object to be thick so that the extrude affects both sides, making thicker on both sides. Or as per the weight value. 0.5 is centered, 1 extrudes down, zero extrudes up.

Also supports object lists so long as faces or mesh objects.

Parameters:
  • obj (list(str)) – The name of the object or face list to extrude

  • thickness (float) – The thickness of the object in Maya units usually cms

  • weight (float) – Controls the direction of the extrude, 0.5 is center and the extrude will go out each side

  • select (bool) – Select the original selection after the extrude completes?

  • message (bool) – Report the message to the user?

centerThicknessNode(obj, nodeType='polyExtrudeFace')

Returns a legit centerThickness node related to obj, of either type:

“polyMoveVertex” “polyExtrudeFace”

Parameters:
  • obj (str) – The name of the object to search the input connections

  • nodeType (str) – either “polyMoveVertex” or “polyExtrudeFace”

Return node:

returns the node name or “” if not found

Rtype node:

str

getExtrudeThickness(obj)

Search for the first extrude node found and if it has a ZOO_THICKNESS_ATTR attribute then return it’s localTranslateZ

Parameters:

obj (str) – A polygon object

Return thickness:

The thickness of the extrudeCenterThickness operation in Maya units, None if not found

Rtype thickness:

float

getExtrudeThicknessSelected(message=True)

Of selected meshes search for the first extrude node found and if it has a ZOO_THICKNESS_ATTR attribute then return it’s localTranslateZ value (thickness)

Parameters:

message (bool) – Report the message to the user?

Return thickness:

The thickness of the extrudeCenterThickness operation in Maya units, None if not found

Rtype thickness:

float

setExtrudeThickness(obj, thickness=1.0, weight=0.5)

Sets the center thickness extrude by affecting two nodes, the polyExtrudeFace node and polyMoveVertex.

Both nodes if a legitimate object with this setup will be marked with the attribute ZOO_THICKNESS_ATTR

Parameters:
  • obj (list(str)) – The name of the object or face list to extrude

  • thickness (float) – The thickness of the object in Maya units usually cms

  • weight (float) – Controls the direction of the extrude, 0.5 is center and the extrude will go out each side

Return success:

True if completed setting both nodes, False if not

Rtype success:

bool

setExtrudeThicknessSelected(thickness=1.0, weight=0.5, message=True)

Sets the center thickness extrude by setting two nodes, the polyExtrudeFace node and polyMoveVertex.

Based on the selection filters for mesh objects in the selection.

Both nodes if a legitimate object with this setup will be marked with the attribute ZOO_THICKNESS_ATTR

Parameters:
  • thickness (float) – The thickness of the object in Maya units usually cms

  • weight (float) – Controls the direction of the extrude, 0.5 is center and the extrude will go out each side

deleteThickness(obj, message=True)

Deletes the thickness setup from an object

Parameters:
  • obj (list(str)) – The name of the object or face list to extrude

  • message (bool) – Report messages to the user

deleteThicknessSelected(message=True)

Deletes the thickness setup from the selected objects

Parameters:

message (bool) – Report messages to the user

Mirror

flip()

Maya’s Mesh > Flip

symmetrize()

Maya’s Mesh > Symmetrize

symmetryToggle(message=True)

Toggles symmetry modelling mode

Parameters:

message (bool) – Report a message to the user?

changeSymmetryMode(symmetryMode='World X', message=False)

Changes the Symmetry modeling mode.

Options (case not important):

“World X” “World Y” “World Z” “Object X” “Object Y” “Object Z”

Parameters:

symmetryMode (str) – “World X” or “Object Y” etc. Can also be an empty string to not affect “”

checkForFrozenGeometry(obj)

Checks to see if the geometry has been frozen, ie it’s rotate pivot is not zeroed.

Uses a tolerance threshold.

Parameters:

obj (str) – A maya object name

Return frozen:

True if the object was frozen

Rtype frozen:

bool

removeFreezeSelected(obj)

Removes the freeze local pivot info from an object while maintaining it’s position.

mirrorPolyEdgeToZero(smoothEdges=True, deleteHistory=True, smoothAngle=180, mergeThreshold=0.001, disableSoftSelect=True, mirrorAxis='x', direction=1, space='world', message=True)

Mirrors poly objects with maya’s polyMirrorFace with additional options.

Can select center verts or edges and will center those while remembering symmetry mode:

  1. Moves selected vertices or edges to the given mirrorAxis center eg X zero

  2. Mirrors object on the mirrorAxis the given axis ie +X to the opposite -X

Can also use in object mode. Supports multiple object selection. Will smooth edges and delete history. Also will switch off softSelect by default

To use: Select the vertices or edges you want on the X axis and run the function credit to Ric Williams (co-author with Andrew Silke)

TODO: add preferences

Parameters:
  • smoothEdges (bool) – Smooth the edges with cmds.polySoftEdge?

  • deleteHistory (bool) – Delete history after the tool completes?

  • smoothAngle (float) – If smoothEdges then this is the angle that the polySoftEdge smooths

  • mergeThreshold (float) – The merge threshold for the polyMirrorFace tool

  • disableSoftSelect (bool) – If in soft select mode make sure it’s turned off for the center line adjust

  • mirrorAxis (str) – The axis for the mirror to affect will be this axis eg “x”

  • direction – Direction of the mirror “-” or “+” negative or positive

  • space (str) – What space is the mirror in “world” or “object”

  • message (bool) – Report the messages to the user?

createMirrorInstanceNetwork(groupMirror, origGroup, mirrorSetupObjName, suffixSide01, suffixSide02)

Creates the network node steup for the mirror instance setup. Connections are made via message connections.

Used while tracking and removing instances.

Parameters:
  • groupMirror (str) – The group name of the mirror side

  • origGroup (str) – The group name of the non mirror side

  • mirrorSetupObjName (str) – The first object in the origObjs, a short name (is instanced so will be doubled)

  • suffixSide01 (str) – The first suffix of the setup “L” or “R” or “top” or “bottom” etc

  • suffixSide02 (str) – The second suffix of the setup “L” or “R” or “top” or “bottom” etc

Return networkNodeName:

The name of the network node created

Rtype networkNodeName:

str

Return mirrorInstanceDict:

dictionary of all object in the setup

Rtype mirrorInstanceDict:

str

retrieveMirrorInstanceList(networkNode)

Given a Mirror Instance network node name return the dictionary with all data.

Note that the mirror objs are instances so it’s impossible to tell if they are mirrored or originals:

{KEY_MIRROR_GRP: “mirrorGroupName_grp”, KEY_MIRROR_OBJS: [“obj1”, “obj2”], KEY_ORIG_GRP: “groupName_grp”, KEY_PARENT_ROOT: None}

The network node may return None if objects have already been deleted. KEY_PARENT_ROOT of None may be world.

Parameters:

networkNode (str) – The name of the Mirror Instance Network node.

Return mirrorInstanceDict:

The returned data containing the applicable transform/object node.

Rtype mirrorInstanceDict:

dict

getInstNetworkNodeFromObj(obj)

From an object check if it is connected the a Mirror Instance network node.

Parameters:

obj (str) – A Maya object name

Return networkNode:

Name of a Maya network node, “” empty string if it None found.

Rtype networkNode:

str

getInstNetworkNodeObjHierarchy(obj)

From an object check if it or any of it’s parent hierarchy is connected the a Mirror Instance network node.

Parameters:

obj (str) – A Maya object name

Return networkNode:

Name of a Maya network node, “” empty string if it None found.

Rtype networkNode:

str

retrieveMirrorInstanceNetworkSel()

From the current selection retrieve all network nodes and their data as dictionaries.

Return networkNodeList:

A list of network node names connected to the current selection

Rtype networkNodeList:

list(str)

Return mirrorSetupDictList:

a list of dictionaries with contents matching the network node names.

Rtype mirrorSetupDictList:

list(dict(str))

cleanupMirrorInstanceNetwork(networkNodeList)

From a network node list remove the setups that are broken.

Parameters:

networkNodeList (list(str)) – A list of mirror instance network node names

Return validNetworkNodes:

A list of netowrk nodes that are not broken.

Rtype validNetworkNodes:

list(str)

Return objs:

Any objects that have been removed from the setup, long names will change as hierarchy change

Rtype objs:

list(str)

instanceMirror(groupName='instance_grp', mirrorAxis='x', space='world', direction='+', message=True)

Instance mirrors selected objects by instance group and duplicate, then invert scale.

Handles naming and network node setup so that the setup can be uninstanced cleanly later.

Also checks for broken networks and if an instanced network already exists.

Parameters:
  • groupName – The non instanced new suffix, by default is “instance_grp”, prefix is first selected object

  • mirrorAxis (str) – The axis for the mirror to affect will be this axis eg “x”

  • space (str) – What space is the mirror in “world” or “local”

  • direction (str) – Which direction is the mirror “+” or “-”, only affects names

  • message (bool) – Report the message to the user

Rtype groupName:

Return group:

Name of the first mirror group

Rtype group:

str

Return groupMirror:

The instanced group mirror name

Rtype groupMirror:

str

uninstanceMirrorInstance(networkNode, mirrorSetupDict)

Uninstance a Mirror Instance setup while unparenting and renaming objects cleanly. Checks for broken setups.

Parameters:
  • networkNode (str) – The name of a Mirror Instance network node

  • mirrorSetupDict (dict) – The dictionary information of the network node

Return objs:

The remaining object list if successful otherwise will be an empty list

Rtype objs:

list(str)

uninstanceMirrorInstanceSel(message=True)

From the selection uninstance a Mirror Instance network selection, if it exists.

Uninstance a Mirror Instance setup while unparenting and renaming objects cleanly. Checks for broken setups.

Return networkNodeList:

A list of Mirror Instance network nodes that have been removed from the scene.

Rtype networkNodeList:

list(str)

uninstanceMirrorInstacesAll()

Uninstance all Mirror Instance networks if they exist.

Uninstances while unparenting and renaming objects cleanly. Checks for broken setups and will remove broken setups.

Return networkNodeList:

A list of Mirror Instance network nodes that have been removed from the scene.

Rtype networkNodeList:

list(str)

Paintfxtube

paintFxTubePolyTube(curve)

From a curve build a poly tube

Parameters:

curve (str) – A curve transform node

Return strokeTransform:

The transform node of the paintFX stroke

Rtype strokeTransform:

str

Return strokeShape:

The shape node of the stroke

Rtype strokeShape:

str

Return meshTransform:

The transform node of the mesh

Rtype meshTransform:

str

Return meshShape:

The shape node of the mesh

Rtype meshShape:

str

paintFxTubeRig(curve, radius=1.0, tubeSections=12, minClip=0.0, maxClip=1.0, density=1.0, polyLimit=200000, buildMetaNode=True)

Create poly tube from a given curve, with paint FX.

Parameters:
  • curve (str) – The curve to build the poly rig ontop of

  • radius (float) – radius of the poly tube

  • tubeSections (int) – The amount of tube radius sections

  • minClip (float) – The minimum clip attribute value

  • maxClip (float) – The maximum clip attribute value

  • density (float) – The density of the poly tube, higher numbers more polys

  • polyLimit (int) – The poly limit of the setup

  • buildMetaNode (bool) – Add a meta setup to the rig for tracking?

Return nodeList:

A list of all the nodes created

Rtype nodeList:

list(str)

paintFxTubeRigSelected(radius=1.0, tubeSections=12, minClip=0.0, maxClip=1.0, density=1.0, polyLimit=200000, message=True, selectMeshes=True)

Adds a paintfx poly tube rig on a selected curve see paintFxTubeRig() for documentation

Pivots

matchPivotParent(obj)

Matches the pivot to the objects parent if it has one, if not match to world center

Parameters:

obj (str) – a Maya transform node

matchPivotParentList(objList)

Matches the pivot to each object’s parent if it has one, if not match to world center

Parameters:

objList (list(str)) – A list of Maya transforms

matchPivotParentSel(message=True)

Matches the selected object’s pivot to each object’s parent if it has one, if not match to world center

centerPivotSelected()

Maya’s center pivot selected command

centerPivotWorld(obj)

Centers the pivot of an object (transform node) to the center of the world or parent zero position.

Parameters:
  • obj (str) – A single Maya object transform node name

  • worldSpace (bool) – Center to the world, False will center to the parent space center

centerPivotWorldList(objList)

Centers the pivot of each object (transform node) in a list to the center of the world or parent zero position.

Parameters:
  • objList (str) – A list of Maya objects, transform node names

  • worldSpace (bool) – Center to the world, False will center to the parent space center

centerPivotWorldSel(message=True)

Centers the pivot of each object (transform node) in a selection to center of the world or parent zero position.

Parameters:

message (bool) – Report a message to the user?

Subdivisions

from zoo.libs.maya.cmds.modeling import subdivisions subdivisions.toggleSubDsSel()

subDSettingsShape(meshShape)

Returns the subdivision settings of the meshShape node

Parameters:

meshShape (str) – The mesh shape node name

Return vpDiv:

Gets the Preview Division Levels attribute on the mesh shape

Rtype vpDiv:

int

Return renderDiv:

Gets the Render Division Levels attribute on the mesh shape

Rtype renderDiv:

int

Return useForRender:

Gets the Use Preview Level For Rendering check box on the mesh shape

Rtype useForRender:

bool

Return showSubDs:

Gets the Display Subdivisions check box on the mesh shape

Rtype showSubDs:

bool

subDSettingsSelected(message=False)

Returns the subdivision settings of the last selected mesh transform

Parameters:

message (bool) – return the message to the user?

Return vpDiv:

Gets the Preview Division Levels attribute on the mesh shape

Rtype vpDiv:

int

Return renderDiv:

Gets the Render Division Levels attribute on the mesh shape

Rtype renderDiv:

int

Return useForRender:

Gets the Use Preview Level For Rendering check box on the mesh shape

Rtype useForRender:

bool

Return showSubDs:

Gets the Display Subdivisions check box on the mesh shape

Rtype showSubDs:

bool

setSubDSettingsShape(meshShape, previewDivisions=2, rendererDivisions=2, usePreview=True, displaySubs=False, subDValue=2, setSubDValue=False)

Sets the subD mesh settings on the mesh shape node for polygon object Maya.

Parameters:
  • meshShape (str) – The mesh shape node name

  • previewDivisions (int) – Sets the Preview Division Levels attribute on the mesh shape

  • rendererDivisions (int) – Sets the Render Division Levels attribute on the mesh shape

  • usePreview (bool) – Sets the Use Preview Level For Rendering check box on the mesh shape

  • displaySubs (bool) – Sets the Display Subdivisions check box on the mesh shape

  • subDValue (int) – Sets subD display to be on off Eg. The 1, 2 or 3 key default shortcuts will be 0, 1 or 2

  • setSubDValue (bool) – if False will not change the current 1, 2, 3 (0, 1, 2) mode of the SubD

setSubDSettingsTransform(obj, previewDivisions=2, rendererDivisions=2, usePreview=True, displaySubs=False, subDValue=2, setSubDValue=False)

Sets the subd mesh settings on a transform polygon node.

Parameters:
  • obj (str) – The transform node name

  • previewDivisions (int) – Sets the Preview Division Levels attribute on the mesh shape

  • rendererDivisions (int) – Sets the Render Division Levels attribute on the mesh shape

  • usePreview (bool) – Sets the Use Preview Level For Rendering check box on the mesh shape

  • displaySubs (bool) – Sets the Display Subdivisions check box on the mesh shape

  • subDValue (int) – Sets subD display to be on off Eg. The 1, 2 or 3 key default shortcuts will be 0, 1 or 2

  • setSubDValue (bool) – if False will not change the current 1, 2, 3 (0, 1, 2) mode of the SubD

setSubDSettingsList(previewDivisions=2, rendererDivisions=2, usePreview=True, displaySubs=False, subDValue=2, setSubDValue=False, message=True)

Sets the subD mesh settings on the current selection

Parameters:
  • previewDivisions (int) – Sets the Preview Division Levels attribute on the mesh shape

  • rendererDivisions (int) – Sets the Render Division Levels attribute on the mesh shape

  • usePreview (bool) – Sets the Use Preview Level For Rendering check box on the mesh shape

  • displaySubs (bool) – Sets the Display Subdivisions check box on the mesh shape

  • subDValue (int) – Sets subD display to be on off Eg. The 1, 2 or 3 key default shortcuts will be 0, 1 or 2

  • setSubDValue (bool) – if False will not change the current 1, 2, 3 (0, 1, 2) mode of the SubD

  • message (bool) – Report the message to the user?

polySmoothMeshes(objs, divisions=1, keepHistory=True)

Adds a polysmooth to selected objects

Parameters:
  • objs (list(str)) – A list of maya meshes

  • divisions (int) – The subdivision level to divide

  • keepHistory (bool) – Keep construction history?

polySmoothMeshesSel(divisions=1, keepHistory=True)

Adds a polysmooth to selected objects

Parameters:
  • divisions (int) – The subdivision level to divide

  • keepHistory (bool) – Keep construction history?

toggleSubDs(meshShapes)

Toggles the Smooth Mesh Preview (SubD on/off) mode of a list of mesh shapes on or off.

Parameters:

meshShapes (str) – A list of mesh shape nodes.

toggleSubDsSel(message=False)

Toggles the Smooth Mesh Preview (SubD on/off) for the selection.

Parameters:

message (bool) – Report a message to the user?

selectedMeshShapes()

Returns the selected mesh shapes or list() if None.

Returns:

A list of mesh shape nodes

Return type:

str

setSubDMode(value)

Sets the subD mode to be off (0), hull (1) or on (2)

Parameters:

value (int) – 0: subD is off. 1: subD is in hull mode. 2: subd is on

class ZooSubDTrackerSingleton(*args, **kwargs)

Bases: object

Used by the subd marking menu & UI, tracks data for subds

_shapes

getRendererIsLoaded(pluginName)

checks if the plugin is loaded

Parameters:

pluginName (str) – the name of the plugin

Return loaded:

is the plugin loaded?

Rtype loaded:

bool

loadSHAPES()

Load the SHAPES Plugin

Return loaded:

did SHAPES get loaded?

Rtype loaded:

bool

checkSymmetrySHAPESCommand()
checkAndLoadSHAPES()
checkSymmetrySHAPES()