Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - kevmitm

Pages: [1]
1
Hi,

I think that in your long running code, you can call in the main thread from time to time
QCoreApplication.processEvents() and that should work ok. Personally, I usually call it in a loop 5 times or so
and that is usually enough to get some responsiveness. Also, make sure to call it frequently.

If you are doing most of the work in another thread, you can check the method here to perform actions on the main thread:
https://docs.substance3d.com/sddoc/using-threads-172825676.html

Est.

Calling QCoreApplication.processEvents() is what I ended up doing and it's good enough. Thanks :)

2
Hi,

Opening graphs is not available in the Python API at the moment.
Maybe you could simulate a double click in the item using Qt for Python but I am not sure how that would work.

Est.

Thanks, I will give it a try.

3
Substance DesignerSubstance Designer - Scripting - How to import pyd file
 on: October 15, 2020, 04:33:49 pm 
Some of my python dependencies cannot be imported inside of Substance Designer.

The following script works perfectly outside of Substance Designer

Code: [Select]
import cryptography
print(cryptography)
from cryptography import hazmat
print(hazmat)
from cryptography.hazmat import bindings
print(bindings)
print(dir(bindings))
from cryptography.hazmat.bindings import _padding
print(_padding)

It outputs the following:

Code: [Select]
PS & 'C:\Program Files\Allegorithmic\Substance Designer\plugins\pythonsdk\python.exe' .\test.py
<module 'cryptography' from 'C:\\Program Files\\Allegorithmic\\Substance Designer\\plugins\\pythonsdk\\lib\\site-packages\\cryptography\\__init__.py'>
<module 'cryptography.hazmat' from 'C:\\Program Files\\Allegorithmic\\Substance Designer\\plugins\\pythonsdk\\lib\\site-packages\\cryptography\\hazmat\\__init__.py'>
<module 'cryptography.hazmat.bindings' from 'C:\\Program Files\\Allegorithmic\\Substance Designer\\plugins\\pythonsdk\\lib\\site-packages\\cryptography\\hazmat\\bindings\\__init__.py'>
<module 'cryptography.hazmat.bindings._padding' from 'C:\\Program Files\\Allegorithmic\\Substance Designer\\plugins\\pythonsdk\\lib\\site-packages\\cryptography\\hazmat\\bindings\\_padding.pyd'>

But the same code inside of Substance Designer fails:

Code: [Select]
[MSG][2]<module 'cryptography' from 'C:\\Program Files\\Allegorithmic\\Substance Designer\\plugins\\pythonsdk\\lib\\site-packages\\cryptography\\__init__.py'>
[MSG][3]<module 'cryptography.hazmat' from 'C:\\Program Files\\Allegorithmic\\Substance Designer\\plugins\\pythonsdk\\lib\\site-packages\\cryptography\\hazmat\\__init__.py'>
[MSG][4]<module 'cryptography.hazmat.bindings' from 'C:\\Program Files\\Allegorithmic\\Substance Designer\\plugins\\pythonsdk\\lib\\site-packages\\cryptography\\hazmat\\bindings\\__init__.py'>
[MSG][5]['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', 'absolute_import', 'division', 'print_function']
[ERR][6]Traceback (most recent call last):
[ERR][7]  File "<string>", line 8, in <module>
[ERR][8]ImportError
[ERR][9]:
[ERR][10]DLL load failed: Le module spécifié est introuvable.

Was dll loading completly disabled in Substance Designer ?

4
This looks nice ! Thanks a lot, I will give it a try  :)

5
I'm showing a progress bar while my script is generating a graph. Although, generating the graph take a longtime and I have 2 issues :
- the progress bar animation is not moving
- we can't click on "Cancel" on the progress dialog

To hack this, I tried to use:
Code: [Select]
QCoreApplication.processEvents()But it doesn't work very well and it's not advised.

After searching online, the advise I see everywhere is to run the long process on another thread. Although, the Substance documentation say that can't use the Substance API from another thread.

So what can I do ?

6
Another answer to myself : there is a python sample showing exactly how to create a complete graph. It's located in:

Code: [Select]
%INSTALL_DIR%/resources/python/scripts/samples/sample_sbs_graph.py

7
Can we open a recently created graph in the view ? Do I need to save it to do so ?

Code: [Select]
    context = sd.getContext()
    app = context.getSDApplication() if context else None
    package_manager = app.getPackageMgr() if app else None
    assert context and app and package_manager

    package = package_manager.newUserPackage()
    graph = create_graph(package, graph_name) if package else None
    assert package and graph

How can I script what happen when I double click on this graph ?




8
Reply to myself : there is a newNode() function which allow to create a graph node. So creating a graph from scratch should be possible.

9
I'm interested in automating the generation of a graph with Python.

By reading the Designer Scripting documentation, it looks like we can only access information in the graph, but not create it. Am I missing something ?

I also read about SAK and it seems it can do this, but I'm curious if we can do this directly from Designer.

Pages: [1]