![]() When listing parents of objects directly under the world, ![]() This command lists parents and children of DAG objects. ListRelatives is undoable, NOT queryable, and NOT Note: Strings representing object names andĪrguments must be separated by commas. If ( cmds.nodeType( obj ) != "shadingEngine" ): # remove the shadingEngine from the selectable set # make a set to hold the selectable nodes If ( cmds.nodeType( obj ) != "mesh" ) and ( cmds.nodeType( obj ) != "transform" ): History = cmds.ls( cmds.listHistory( nodes ), long=True ) # look at history to find input connections ![]() # look at future to find output connections (shadingEngine)įuture = cmds.ls( cmds.listHistory( obj, f=True ), long=True ) Here is the edited script: # returns a list of all nodes connected or related to the selection If it’s included, the script will select all members of the shadingEngine, and consequently, unrelated mesh shapes, which is not what I want. There’s also an extra step at the end where I have to exclude the shadingEngine from the result selectable set. Once the shadingEngine is in the set, I only need to look at input connections (history) and exclude any shape nodes from there. This will get me the shadingEngine from whatever group or mesh selected in the outliner. I found that I only need to do one call of listRelatives() for future. The reason that unrelated objects (shape nodes) would become selected was due to the shadingEngine node. Is there a more reliable way to get all connections? So looping through 2 times seems to work in my particular scene, but I have no idea why this is and whether this script will work on a different scene, for example, if the shader network has a greater depth than the materials in my current scene. 3 times, I get all other shape nodes in my scene even if they are not related or connected to my selection.2 times, I get the materials and their file nodes.If you notice the block of code at # add all connected nodes, if I loop through this… Sel = cmds.ls( selection=True, long=True )ĬonnectedNodes = getAllConnectedNodes( sel ) Hist = cmds.ls( cmds.listHistory( obj ), long=True )įtr = cmds.ls( cmds.listHistory( obj, f=True ), long=True ) Nodes = nodes.union( set( parentsList ) ) Parents = cmds.ls( sel, long=True ).split( '|' ) # add all relatives of all selected objectsĭesc = cmds.listRelatives( obj, ad=True, f=True ) # returns a list of all nodes connected or related to the selection Here is my script so far… import maya.cmds as cmds That said, I can get the material by repeating the process a second time on all connected objects that are one step away. However, if I select a mesh and do this, it won’t return the material assigned to the object. I understand that input and output connected nodes can be accessed via listHistory() or listHistory( f=True ). I’ve started writing and testing the script but I’m a bit caught up on how to achieve point #2. These might be construction history nodes, shader nodes (materials, file nodes, ramps, etc.) When I say ‘connected’ these are either direct connections, or nodes connected via other nodes through any ‘n’ number of steps.When I say ‘related’ these are parents or children any ‘n’ number of steps away.I’m working on a script where the user selects a series of meshes or groups in the Maya outliner and when the script is run, it returns a list of all nodes that are connected or related to any object in the selection.
0 Comments
Leave a Reply. |