Author Topic: Questions about Python API  (Read 430 times)

Hello !

I'm new to the python API for substance designer and right now I'm trying to make a publishing tool and have couple questions, so is there any way to :

1. get the name of the current graph in the package ?
2. get the function/info in the 3D View ? (I'm trying to reset the position then save the image into specified location)

Thank you !

I only have access to Designer at work so the code snippets I'm providing are from referencing the docs and completely untested, however it should be enough to point you in the right direction.

Quote
1. get the name of the current graph in the package ?
Code: [Select]
import sd.api.qtforpythonuimgrwr ui_mgr
graph = ui_mgr.getCurrentGraph()
graph_name = graph.getIdentifier()

Quote
2. get the function/info in the 3D View ? (I'm trying to reset the position then save the image into specified location)
Unfortunately there's no way to interact with the 3d view via SD API.

If you're trying to generate a swatch to go with your publish, you can try the following:
A:
  • Create a template scene with a sphere (or other obj) and shader in the dcc/renderer of your choice.
  • During publish, export graph outputs via sd.tools.export.exportSDGraphOutputs
  • Trigger a subprocess to plug the textures into the shader of your template scene, via headless/python session and render the outputs.

B:
  • If you're familiar with QT, you can try to capture the 3d viewport object and force the camera changes.
  • Try to export the current view via public methods.

The latter option would require a decent amount of QT knowledge, not to mention being a very hackey solution and not at all future proof. Not recommended but listing it anyways in case you know what you're doing.
Last Edit: December 21, 2019, 05:09:32 pm