PyMel: Difference between inputs() vs history()?

TL,DR: What are the differences in behavior between history() and inputs() in PyMEL?

Hey all, this is my first post, and a long one at it! trying to be thourough for posterity.

I have been using the PyNode.history() function all over the place over the past semester without too much issues. But lately I have run into issues with it.

Here’s what I gather so far:

history() is a PyNode function, and until recently seems to be an easy way to recursively access nodes in the graph.

inputs() is a DependNode function, and seems to give first level graph connections (so technically, should be the equivalent of history(levels=1))

Recently, I was using history() as a quick way to access shading nodes by starting from a Shading Engine

eg, to find the closest file node:

fileNode = None
sgHistory = shadingEngine.history(breadthFirst=True)

for figure in sgHistory:
    if figure.nodeType() == 'file':
        fileNode = figure
return fileNode

This seemed to work marvelously for a time.

But today I wrote a UV-linking script using this method, meaning now Mesh objects are connected to the Shading Engine (through the UvChooser Node created by a UV link).

This seems to have broken history():

It now only returns mesh nodes.

However inputs() returns the correct nodes (including the Material) but for my purposes isn’t as handy because non-recursive.

So that’s the context. I’m assuming this is just a PyMEL bug, but I figured this was a good occasion to try to settle which function suits which situation.

Thanks all, let me know if this needs clearing up!

So those methods are just shorthand for cmds.listConnections and cmds.listHistory

So it might help giving those a read through, and see if that helps you understand?
(Honestly I’m fuzzy on the differences, but mostly because I’ve not used either command in a good long while)


Thanks bob, the cmds.listHistory doc does hint at a way to use these:

For information on history connections through specific plugs use the “listConnections” command first to find where the history begins then use this command on the resulting node.

I’d like to leave the conversation open though in case anyone has studied the distinction a bit more in depth. Some quirks (whether in PyMEL or cmds) like the one I described remain unresolved despite this.

I’m hoping we can document a solid way to navigate the maya graph with the info.