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.


Topics - kevmitm

Pages: [1]
1
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 ?

2
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 ?

3
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 ?




4
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]