Copy link to clipboard
Copied
Really, all I need is the x:y aspect ratio, but I'd by happy to discover a way to get the size as well. The .sbs has a base parameter called "defaultParentSize" which is essentially what I'm looking for, but there doesn't appear to be a way to get it in the python API
Any help would be greatly appreciated.
I've figured out a hacky workaround until this is officially supported.
from sd.api.sdproperty import SDPropertyCategory
def get_graph_resolution(api):
graph = api.ui_mgr.getCurrentGraph()
# create a temp output node:
output_node = graph.newNode('sbs::compositing::output')
# we have to compute the graph, unfortunately, or else the output node won't have any properties:
graph.compute()
# get the output texture:
properties = output_node.getProperties(SDPropertyCategory
...
Copy link to clipboard
Copied
I've figured out a hacky workaround until this is officially supported.
from sd.api.sdproperty import SDPropertyCategory
def get_graph_resolution(api):
graph = api.ui_mgr.getCurrentGraph()
# create a temp output node:
output_node = graph.newNode('sbs::compositing::output')
# we have to compute the graph, unfortunately, or else the output node won't have any properties:
graph.compute()
# get the output texture:
properties = output_node.getProperties(SDPropertyCategory.Output)
texture = output_node.getPropertyValue(properties[0]).get()
# this is all we need:
x, y = texture.getSize()
# delete the output node:
graph.deleteNode(output_node)
return x, y
There are a few things that aren't ideal about this workaround:
If anybody has a better solution please let me know.
Thanks!
Copy link to clipboard
Copied
Hello @SIE Jake H,
This is a nice little hack indeed, well done!
I appreciate wour patience until we expose the defaultParentSize attribute in the Python API.
Best regards.