Copy link to clipboard
Copied
Hi, Texture/Material Gurus.
By the help of Substance Designer's Python Editor, I'm trying to draw/plot some complex sine waves such as "Squeeze Theorem / Sandwich Theorem" shown below:
[squeeze theorem example]
I'm trying to somehow use Matplotlib in SD's Pixel Processor to plot diverse functional graphs.
But, a week-long intensive googling has failed to find a solution to import external or 3rd party Python libraries or api to Substance Designer. Its internal Python Editor keeps prompting error logs like this:
 
[Numpy & Matplotlib are installed in the right directory. But, Substance Designer's Python Editor can't read\/recognize Numpy??]
On my PC, I've installed all most every existing Python functional graph-drawing Libraries, such as Matplotlib, Numpy, Turtle, Tkinter, Sympy, Pysound, Graphviz, Plotly, etc. in the right directory/path recognizable for SD as a test.
But, it seems like SD doesn't read or recognize those libraries, escpecially Numpy (which, I guess, the core library for the other major graph visualizing Libraries)
Is there any way to make Substance Designer successfully import Numpy and Matplotlib?
Please save me from this cliff,
Thank you!
Copy link to clipboard
Copied
Hello,
You may add the directory where the Python modules are installed to the PYTHONPATH environment variable, to make it discoverable by Designer's own Python interpreter.
If the module still cannot be imported at that point, you can force the module discovery with the following:
my_module_path = os.path.join(os.environ["PYTHONPATH"], "my_module")
if my_module_path not in sys.path:
sys.path.append(my_module_path)
import my_module
I hope this helps!
Best regards.
Copy link to clipboard
Copied
Thank you for your reply, Luca.
(My os is Windows 10)
I tried my best to refer to you in my code as follows:
import sys
sys.path.append('C:\Program Files\Adobe\Adobe Substance 3D Designer\plugins\pythonsdk\Lib\site-packages')
numpy_path = os.path.join(os.environ['C:\Program Files\Adobe\Adobe Substance 3D Designer\plugins\pythonsdk\Lib\site-packages'], 'my_numpy')
if numpy_path not in sys.path:
sys.path.append(numpy_path)
import my_numpy
But, it prompted an error like below:
[MSG][1]File saved: 'G:/OneDrive/Desktop/moduleimport_test_1.py'
[MSG][2]Run 'moduleimport_test_1.py' (G:/OneDrive/Desktop/moduleimport_test_1.py)...
[ERR][3] File "G:/OneDrive/Desktop/moduleimport_test_1.py", line 2
[ERR][4]
[ERR][5]sys.path.append('C:\Program Files\Adobe\Adobe Substance 3D Designer\plugins\pythonsdk\Lib\site-packages')
[ERR][6]
[ERR][7]^
[ERR][8]IndentationError
[ERR][9]:
[ERR][10]unexpected indent
[MSG][11]Run finished.
[MSG][12]File saved: 'G:/OneDrive/Desktop/moduleimport_test_1.py'I've got a very few knowledge in solving such errors.
Could you please guide me through a little bit further?
Thank you!
Copy link to clipboard
Copied
Hello,
Thank you for the code sample, this helps me provide guidance regarding this issue.
The error points to an IndentationError at line 2 of the moduleimport_test_1.py script. And, indeed this line is indented when it should not be:
sys.path.append('C:\Program Files\Adobe\Adobe Substance 3D Designer\plugins\pythonsdk\Lib\site-packages')
Remove the identation to solve the error.
Two other issues I have noticed:
You should only need to do the following:
import sys
numpy_path = os.path.join('C:\Program Files\Adobe\Adobe Substance 3D Designer\plugins\pythonsdk\Lib\site-packages', 'my_numpy')
if numpy_path not in sys.path:
sys.path.append(numpy_path)
import my_numpy
Additionally, I recommend placing your Python module in another location which is separate from Designer's installation files. This ensures your custom modules stay intact in case of Designer being uninstalled, upgraded or other modifications to its installation.
This separate location should then be added to the PYTHONPATH environment variable, so the Python interpreter finds and inspects it during module import statements. To add a directory to the PYTHONPATH, you may refer to this guide.
Best regards.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more