Getting Inputs/Input Order [Maya]

I’m trying to get the deformer/input order on a mesh as it appears in the channel box under “INPUTS”. I’ve tried using listHistory and then double checking the nodeTypes for the ‘geometryFilter’ inherited type.

This is a technique that I found searching through these forums. It works well except for one issue. listHistory traverses the entire chain, so I’m getting blendshapes and deformers that are driving the meshes of the blendshapes that my script is interested in. If I’m only interested in the deformer list as it appears in the channel box, is there an easy way to get that list?

Why not just look at connections to the input attribute of the deformer? They should be returning in the order from lowest array index to highest.

Otherwise you can use the levels flag of the listHistory command to get the history for a portion of the chain.

EDIT:
Additionally, you can query the inputs of a deformer using the deformer command with -q and -g flags

What is it you’re trying to achieve? Why do you need exact replica of what’s there in the channel box? in the dependency graph, you can’t think of “inputs” as a list - shape is formed by a graph of nodes, and how you display stuff in a list is subjective. There’s also “important” (like deformers or constraints) and “not very important” (conversion nodes) items in the list, or stuff you just want to omit as an “input” (like source mesh for a blend shape).

I want to make something that can be thought of as “BakeTopologyToTargetsRigged”. This tool is for meshes that have both skinning and rigged blendshapes attached to it. The user would use it when they want to make tweaks or topology adjustments to a rigged mesh with blendshapes, then push those changes out to the targets.

I’m using the technique from Steve Roselle’s tips and tricks video on youtube - https://www.youtube.com/watch?v=BFPAIU8hwQ4

The problem is that I need to re-arrange the deformer inputs so that the tweak node happens before the blendshape node, bake the topology to targets, and then put the tweak node back again afterwards. To do that I need to be able to grab the list of inputs as it appears in the channel box list (or the inputs window that you can bring up). Right now, listHistory traverses the history way too far, so I am getting deformers that are connected to target blendshapes that I’m not interest in using. Once I can get this list, then I can use maya’s reorderDeformers command to put the tweak back at the end of the list.

Then I guess you just need to traverse up the connections on the “input” attribute, something like


history = empty list;
currentGeomFilter = final shape;
while currentGeomFilter is not null:
    add currentGeomFilter to history;
    currentGeomFilter = get connected node on the "currentGeomFilter.input"