Search code examples
pythonnuke

Select NUKE nodes, where class of a nodes starts with string "OFXuk"


Any idea how to create a script that can select nodes of same class that starts with class name "OFXuk"

for example if i have list of nodes, with different class as below

OFXuk.ab.cdef.ghi_node1
OFXuk.ab.cdef.ghi_node2
OFXuk.ab.cdef.ghi_node3

I want to select all three nodes by their common starting string "OFXuk"


Solution

  • Try the following code snippet for selecting Furnace-class nodes:

    enter image description here

    import nuke
    
    for index in nuke.allNodes():
        nodeClass = index.Class()
    
        if nodeClass.__contains__("OFXuk"):
            index.setSelected(True)
    

    enter image description here

    Hope this helps.