Skip to main content
Known Participant
April 16, 2025
Open for Voting

PythonApi - Select nodes from script

  • April 16, 2025
  • 3 replies
  • 494 views

It would be incredibly useful for validation tooling (in studios) to be able to select a list of nodes via the python api. 

Example being - running validation on a graph and finding nodes that don't match some specification and being able to select the nodes so a user can address them in whatever way is necessary 

    3 replies

    Luca Giarrizzo
    Community Manager
    Community Manager
    April 17, 2025

    Thank you for the detailed feedback. These are fair points we have discussed in the past.

    While powerful tools can definitely be achieved with our API, I agree there are structural problems and some tasks are convoluted for no obvious reason.

     

    I have shared your feedback internally for discussion.

     

    Have a pleasant rest of the week!

    Luca Giarrizzo | Quality Engineer - Substance 3D Designer | Adobe
    TooLzorAuthor
    Known Participant
    April 17, 2025

    Thanks @Luca Giarrizzo , Having used the designer api off and on for a few years I always feel like it really needs some love overall...It feels very unpythonic and more like a brute force wrapper around C++ or something. 

    From a tools perspective it does feel like a chore to look through the docs to try to figure out how to interact with nodes rather than get on with building things with it.

     

    E.g. Getting the outputsize of an output node - I can see in the graph when it says 2048 under it, but it feels like it could be a lot easier to get this information in the api 

    In this example, it feels like I should just be able to do:

     

    import sd
    ctx = sd.getContext()
    app = ctx.getSDApplication()
    graph = app.getUIMgr().getCurrentGraph()
    output_nodes = graph.getOutputNodes()
    print("\n".join([x.getOutputSize() for x in output_nodes]))

    Instead of this - having to get properties, transform it into another class to then get the size of it...

    import sd
    from sd.api.sdproperty import SDPropertyCategory
    from sd.api.sdvaluetexture import SDValueTexture
    
    ctx = sd.getContext()
    app = ctx.getSDApplication()
    uiMgr = app.getQtForPythonUIMgr()
    
    def get_output_size(node):
        prop = node.getProperties(SDPropertyCategory.Output)
        value = node.getPropertyValue(prop[0])
        sd_texture = SDValueTexture.get(value)
        size = sd_texture.getSize()
        return size
    
    graph = app.getUIMgr().getCurrentGraph()
    graph.compute()
    for node in graph.getOutputNodes():
        size = get_output_size(node)
        print(f"{node.getDefinition().getLabel()} size is {size}")

     I assume part of it is there's probably output nodes that "don't have a size" or something but surely there must be a more userfriendly/dev friendly wrapper that could be made - especially since it doesn't feel like we have full access to the capabilities of designer from this api as it is currently..

    Luca Giarrizzo
    Community Manager
    Community Manager
    April 17, 2025

    Hello @TooLzor,

     

    Thank you for the feedback! I have shared your suggestion and use case with the rest of the team.

    Feel free to let us know about any other requests you have for Designer's Python API.

     

    Best regards.

    Luca Giarrizzo | Quality Engineer - Substance 3D Designer | Adobe