pymel.core.general.cycleCheck

cycleCheck(*args, **kwargs)

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.

Flags:
Long name (short name) Argument Types Properties
all (all) bool ../../../_images/create.gif
 
search the entire graph for cycles instead of the selection list. (Note: if nothing is selected, -all is assumed).
children (c) bool ../../../_images/create.gif
 
Do not consider cycles on the children, only the specified plugs
dag (dag) bool ../../../_images/create.gif
 
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) bool ../../../_images/create.gif ../../../_images/query.gif
 
Turn on and off cycle detection during graph evaluation
firstCycleOnly (fco) bool ../../../_images/create.gif
 

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) bool ../../../_images/create.gif
 

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) bool ../../../_images/create.gif
 

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).Flag can appear in Create mode of commandFlag can have multiple arguments, passed either as a tuple or a list.

list (l) bool ../../../_images/create.gif
 
Return all plugs involved in one or more cycles. If not specified, returns a boolean indicating whether a cycle exists.
listSeparator (ls) unicode ../../../_images/create.gif
 

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) bool ../../../_images/create.gif
 
Do not consider cycles on the parents, only the specified plugs
secondary (s) bool ../../../_images/create.gif
 
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 ../../../_images/create.gif
 
Limit the search to the given amount of time

Derived from mel command maya.cmds.cycleCheck

Example:

import pymel.core as pm

# Print a message if xNode.tx is in a cycle.
pm.createNode( 'transform', n='xNode' )
# Result: nt.Transform(u'xNode') #
if pm.cycleCheck('xNode.tx') " 0:
  print('xNode.tx is in a cycle')

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

# Print a message if there are any cycles in the graph.
if pm.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.
pm.cycleCheck(all=True,dag=True,l=True )

Previous topic

pymel.core.general.curveRGBColor

Next topic

pymel.core.general.delete

Core

Core Modules

Other Modules

This Page