Skip to main content
Inspiring
February 13, 2025

Python API: SDUIMgr.focusGraphNode() issue

  • February 13, 2025
  • 6 replies
  • 766 views

Hi, I am experimenting with SDUIMgr.focusGraphNode() and it seems this is not working for items inside a PixelProcessor or an FXMap. Is this a known issue?

6 replies

Luca Giarrizzo
Community Manager
Community Manager
March 25, 2025

Noted, I observed the same. Thank you!

 

Luca Giarrizzo | Quality Engineer - Substance 3D Designer | Adobe
Inspiring
March 25, 2025

Thanks Luca, I also noticed we cannot open parameter function graphs with openResourceInEditor()

Luca Giarrizzo
Community Manager
Community Manager
March 25, 2025

Hello Olivier,

 

Thank you for providing this sample script and for your patience. I can reproduce these issues.

 

Indeed, graphs referenced by Pixel Processor and FX-Map nodes cannot be opened using the openResourceInEditor() method, and trying to focus on nodes in these graphs using the focusGraphNode() method results in SDApiError.Undefined exceptions.

 

I have reported these bugs to the team, with a sample graph and script. I will also reference this thread in the bug report.

 

Thank you for your help!

 

Luca Giarrizzo | Quality Engineer - Substance 3D Designer | Adobe
Inspiring
March 22, 2025

@Luca Giarrizzo  can you please try with the code below (call "test_openingAndFocusing()" in your plugin) ? You'll need to have open in Designer a single package with a single graph having at least 2 nodes, an FX-Map and an Pixel Processor, with at least one node inside each of them. The code will try to open the FX-Map or Pixel Processor (depending on flag "use_fx_map") in the editor and focus on the first found node inside either of them. You will see there are multiple problems:

- one is the openResourceInEditor call will not open the content of the FX-Map or Pixel Processor

- another is an exception when focusing on the node (the exception does not trigger always, I've seen it for the Pixel Processor, it may depend if graph is open (manually) or not.

[ERR][1050][Python]  File "C:\Program Files/Adobe/Adobe Substance 3D Designer/resources/python\sd\api\sduimgr.py", line 350, in focusGraphNode
[ERR][1051][Python]    raise APIException(SDApiError(_res))
[ERR][1052][Python]sd.api.apiexception.APIException: SDApiError.Undefined

 

The code to insert in your plugin:

 

import sd
from sd.api.sdgraph import SDGraph

def test_graphViewIDFromGraph(graph):
    ui_mgr = sd.getContext().getSDApplication().getUIMgr()
    count = ui_mgr.getGraphViewIDCount()
    for i in range(0, count):
        graphViewID = ui_mgr.getGraphViewIDAt(i)
        g = ui_mgr.getGraphFromGraphViewID(graphViewID)
        if g.getIdentifier() == graph.getIdentifier():
            return graphViewID
    return None

def test_focusFirstNodeInGraph(graph):
    sd_app = sd.getContext().getSDApplication()
    ui_mgr = sd_app.getUIMgr()
    nodes = graph.getNodes()
    for n in range(0, nodes.getSize()):
        node = nodes.getItem(n)
        print('Opening ' + str(graph))
        ui_mgr.openResourceInEditor(graph)
        gvid = test_graphViewIDFromGraph(graph)
        if gvid:
            print('Found graph view ID ' + str(gvid))
            print('Focusing on '+ str(node))
            ui_mgr.focusGraphNode(gvid, node)
        else:
            print('graph view id not found for graph ' + str(graph))
        break

def test_openingAndFocusing():
    use_fx_map = False   # True to open and focus on node in FX-Map, False to open and focus on node in Pixel Processor
    sd_app = sd.getContext().getSDApplication()
    packages = sd_app.getPackageMgr().getUserPackages()
    for p in range(0, packages.getSize()):
        pkg = packages.getItem(p)
        resources = pkg.getChildrenResources(False)
        if resources:
            for r in range(0, resources.getSize()):
                resource = resources.getItem(r)
                if isinstance(resource, SDGraph):
                    nodes = resource.getNodes()
                    for n in range(0, nodes.getSize()):
                        node = nodes.getItem(n)
                        definition_id = node.getDefinition().getId()                         
                        if (use_fx_map and definition_id == 'sbs::compositing::fxmaps') \
                            or (not use_fx_map and definition_id =='sbs::compositing::pixelprocessor'):
                                graph = node.getReferencedResource()
                                test_focusFirstNodeInGraph(graph)
Inspiring
February 28, 2025

Would you have an example code/graph with this working? I have tried many times in my plugin and it won't work for me. This is not the only problem, openResourceInEditor() also fails to open the content of a Pixel Processor or an FX-Map. This is a pre-requisite to use focusGraphNode().

Luca Giarrizzo
Community Manager
Community Manager
February 13, 2025

Hello @_Olivier_L,

 

The method appears to work in function graphs and FX-Map graphs in my testing.

Can you share your script and Console output when the method fails to work as expected?

 

As a starting point, I suggest checking that Graph view IDs are tracked and updated reliably before being  passed to the focusGraphNode() method.

 

Best regards.

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