Are there any Python videos and / or API documentation for the Python API?
Cheers
Braden
Are there any Python videos and / or API documentation for the Python API?
Cheers
Braden
Does Silhouette have the ability to have user startup scripts?
Scripts that should be invoked as part of app launching.
Is it possible to have a company based menu for Silhouette, to launch our custom scripts.
The main customization page is here, which is available from the Silhouette help menu: Silhouette Wiki
Marco or Paul will probably be able to give you more information on the specifics of the Python API, but the reference is a good place to start.
Thanks.
I have a need to expose some more pipeline modules via PYTHONPATH.
I noticed PYTHONPATH is not set when I start Silhouette. If I try to override it to expose my custom Python modules, I get the following error on Silhouette startup.
ModuleNotFoundError: No module named ‘tools.objectIterator’; ‘tools’ is not a package.
Is it possible to override PYTHONPATH and get expected behaviour.
Check out Help → Customization - it’ll point you to the documented API. But it’s not entirely up-to-date. Your best bet is to take a look in resources/scripts/actions. All of the stuff in the Actions menu is implemented there, as well as some context menu functionality for some of the tools.
Yes - you can add additional script paths in Preferences->Scripting, and even paste in startup code if you’re running 2022.5 or higher. Otherwise, the default startup script (resources/scripts/startup.py) attempts to import sfxsite, sfxuser, and userkeybinds modules. Point your additional script paths there and create those modules and they will get loaded during startup.
Yes, when you create custom actions, you can add them to your own top-level menu by specifying a root=“Name” attribute in init.
You can also put custom actions in the File and Edit menus, as well in some tool context menus (like the Reshape and Transform tool menus).
For example, to put the Select->All action into a top-level Braden menu, you’d do something like this:
class SelectAll(Action):
"""Selects all visible objects in the current node, including Layers."""
def __init__(self):
Action.__init__(self, "Select|All", root="Braden")
If you want to override PYTHONPATH be sure to also include Silhouette’s resources/scripts folder. Or you can use the Scripting preference to add your own paths instead.
If you want to override PYTHONPATH be sure to also include Silhouette’s resources/scripts folder.
Do you have an example of what I need to set on the PYTHONPATH.
When I attempt to read the os.environ[“PYTHONPATH”] after loading Silouette exe. It returns that the key is missing.
The problem I’m having is the PYTHONPATH I want to add from our pipeline has a folder / module called “tools”.
When Silouette starts up it’s also looking to load tools from the folder
resources/scripts/tools
This seems to cause a problem during startup. Which cause many of the actions to not load.
ModuleNotFoundError: No module named ‘tools.objectIterator’; ‘tools’ is not a package.
It seems the “tools” module name isn’t explicit enough.
When I print “tools” after loading Silouttte with my environment variables set on PYTHONPATH, I get this
<module ‘tools’ from ‘C:\OpenPype\igniter\tools.py’>
Try placing Silhouette’s scripts path first in your PYTHONPATH, so it gets priority.
I sorted the PYTHONPATH tools problem.
I don’t want the user to need to add my scripts folder, which environment variable do I use to specify my own scripts file. I tried both
SFX_SCRIPT_PATH
SFX_USER_PATH
However I can’t see my action in the actions menu. Is there anything else you need to get custom actions / menu to show up?
I managed to make my script load by using the Preference dialog, instead of an environment variable.
And making my scripts folder have an init.py file, which imports the startup script I want to execute.
But the questions remains how to specify a script folder via environment variables. Since users wont be visiting the Preference dialog.
I’m wondering how can you use a different PySide2 library?
The pipeline tool I’m trying to import uses the QtSvg class.
The build of PySide2 I have available, separate from Silhouette includes this class.
For some reason BorisFX PySide2 does not have the QtSvg class.
SFX_PYSIDE = can be used to specified an alternate location to load the PySide2 modules from
I saw this in the docs, but when I run this in Silhouette after the app loads. I get this
import PySide2
print(PySide2.file)
C:\Program Files\BorisFX\Silhouette 2022.0\resources\python\lib\site-packages\PySide2_init_.py
Therefore it seems like the environment variable is having no effect.
I managed to get my custom PySide module to load, by putting it on the PYTHONPATH, instead of using SFX_PYSIDE environment variable.
However all the imports fail via Qt.py (which chooses which Qt binding to use). Making me think my “OP” PySide2 isn’t compatible somehow.
Is there a reason the default PySide2 provided by Silhouette excludes QtSvg?
Our PySide2 is a subset of the full package. I’ll see about getting it included.
Oh okay. Do you have any estimates of how long a release would take?
In the meantime, specifying our custom PySide2 directory doesn’t look to be supported.
At the moment, we can’t get you a timeline on adding this PySide2 change.
@bradenjennings I have added this is a feature request for Silhouette 2023.5 scheduled for a late summer or early fall release.