'Get list of shot nodes and set trackstate in Maya using Python API

I am trying to get a list of shot nodes from the sequencer in Maya and then set their track state attribute, but I have not really used the Python API nor do I even understand how to print out the info.

https://help.autodesk.com/view/MAYAUL/2020/ENU/index.html?guid=__Nodes_shot_html

Here is what I have so far:

import maya.api.OpenMaya as newOM

it = newOM.MItDependencyNodes(newOM.MFn.kShot)
while not it.isDone():
    print(it.thisNode())
    it.thisNode().trackState = 18
    it.next()


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source