Go to: Synopsis. Return value. Flags. Python examples.

Synopsis

cycleCheck( string[] , [all=boolean], [children=boolean], [dag=boolean], [evaluation=boolean], [firstCycleOnly=boolean], [firstPlugPerNode=boolean], [lastPlugPerNode=boolean], [list=boolean], [listSeparator=string], [parents=boolean], [secondary=boolean], [timeLimit=time])

Note: Strings representing object names and arguments must be separated by commas. This is not depicted in the synopsis.

cycleCheck is undoable, queryable, and NOT editable.

This command searches for plug cycles in the dependency graph. If a plug or node is selected then it searches for cycles that that plug or node is involved with. Plugs or nodes can also be passed as arguments. If the -all flag is used then the entire graph is searched.

Normally the return value is a boolean indicating whether or not the given items were involved in a cycle. If the -list flag is used then the return value is the list of all plugs in cycles (involving the selected plug or node if any).

Note that it is possible for evaluation cycles to occur even where no DG connections exist. Here are some examples:

1) Nodes with evaluation-time dependent connections: An example is expression nodes, because we cannot tell what an expression node is actually referring to until it is evaluated, and such evaluation-time dependent nodes may behave differently based on the context (e.g. time) they are evaluated at. If you suspect a cycle due to such a connection, the best way to detect the cycle is through manual inspection.

2) Cycles due to DAG hierarchy: noting that DAG nodes are implicitely connected through parenting, if a child DAG node connects an output into the input of a parent node, a cycle will exist if the plugs involved also affect each other. In order to enable detection of cycles involving the DAG, add the -dag flag to the command line.

Note also that this command may incorrectly report a cycle on an instanced skeleton where some of the instances use IK. You will have to examine the reported cycle yourself to determine if it is truly a cycle or not. The evaluation time cycle checking will not report false cycles.

Return value

booleanin the general case.
string[]When the list flag is used.

In query mode, return type is based on queried flag.

Flags

all, children, dag, evaluation, firstCycleOnly, firstPlugPerNode, lastPlugPerNode, list, listSeparator, parents, secondary, timeLimit
Long name (short name) Argument types Properties
all(all) boolean create
search the entire graph for cycles instead of the selection list. (Note: if nothing is selected, -all is assumed).
children(c) boolean create
Do not consider cycles on the children, only the specified plugs
dag(dag) boolean create
Also look for cycles due to relationships in the DAG. For each DAG node, the parenting connection on its children is also considered when searching for cycles.
evaluation(e) boolean createquery
Turn on and off cycle detection during graph evaluation
firstCycleOnly(fco) boolean create
When -list is used to return a plug list, the list may contain multiple cycles or partial cycles. When -firstCycleOnly is specified only the first such cycle (which will be a full cycle) is returned.
firstPlugPerNode(fpn) boolean create
When -list is used to return a plug list, the list will typically contain multiple plugs per node (e.g. ... A.output B.input B.output C.input ...), reflecting internal "affects" relationships rather than external DG connections. When -firstPlugPerNode is specified, only the first plug in the list for each node is returned (B.input in the example).
lastPlugPerNode(lpn) boolean create
When -list is used to return a plug list, the list will typically contain multiple plugs per node (e.g. ... A.output B.input B.output C.input ...), reflecting internal "affects" relationships rather than external DG connections. When -lastPlugPerNode is specified, only the last plug in the list for each node is returned (B.output in the example).
list(l) boolean create
Return all plugs involved in one or more cycles. If not specified, returns a boolean indicating whether a cycle exists.
listSeparator(ls) string create
When -list is used to return a plug list, the list may contain multiple cycles or partial cycles. Use -listSeparator to specify a string that will be inserted into the returned string array to separate the cycles.
parents(p) boolean create
Do not consider cycles on the parents, only the specified plugs
secondary(s) boolean create
Look for cycles on related plugs as well as the specified plugs Default is "on" for the "-all" case and "off" for others
timeLimit(tl) time create
Limit the search to the given amount of time

Flag can appear in Create mode of command Flag can appear in Edit mode of command
Flag can appear in Query mode of command Flag can have multiple arguments, passed either as a tuple or a list.

Python examples

import maya.cmds as cmds

# Print a message if xNode.tx is in a cycle.
cmds.createNode( 'transform', n='xNode' )
if cmds.cycleCheck('xNode.tx') > 0:
  print('xNode.tx is in a cycle')

# Get the list of plugs in a cycle with xNode.ty
cmds.connectAttr( 'xNode.tx', 'xNode.ty' )
cmds.connectAttr( 'xNode.ty', 'xNode.tx' )
cycles = cmds.cycleCheck()

# Print a message if there are any cycles in the graph.
if cmds.cycleCheck(all=True, tl='10sec') > 0:
  print("Your graph has a cycle.")
else:
  print("Your graph probably does not have a cycle")

# List all cycles involving the DG and DAG hierarchy.
cmds.cycleCheck(all=True,dag=True,l=True )