Documentation for Substance 3D Sampler is now available on Experience League. After March 14th, HelpX pages will automatically redirect to the equivalent Experience League page.
Refer to the FAQ for more information about which documentation is affected.
- Substance 3D home
- Home
- Getting Started
- Getting Started overview
- Activation and licenses
- System requirements /content/help/en/substance-3d-sam
- Shortcuts
- Importing Resources
- Report a bug
- Project Management
- Export
- Export overview
- Export Window
- Default Presets
- Managing custom presets
- Managing Presets
- Interface
- Interface overview
- The Home Screen
- 2D and 3D Viewport
- Sidebars
- Panels
- Tools and Widgets
- Preferences
- Filters
- Filters overview
- Custom Filters
- Compound Filters
- Generators
- Adjustments
- Tools
- Tools overview
- Atlas Creator
- Atlas Splitter
- Auto Tiling
- Channels Generation
- Channel Switch
- Clone Stamp
- Crop tool
- Delight (AI Powered)
- Height to AO
- Height to Normal
- Image To Material
- Make it Tile
- Match
- Multiangle To Material
- Normal to Height
- Paint Wrap *missing*
- PBR Validate
- Perspective Correction
- Tiling
- Transform
- Warp
- Warp Transform
- Upscale
- HDRI Tools
- Wear and Finish
- Technical Support
- Technical Support overview
- Exporting the log file
- Configuration
- Technical Issues
- Data or project issues
- Filter issues
- Interface issues
- Performance issues
- Stability issues
- Startup issues
- Features and workflows
- Pipeline and integrations
- Scripting and Development
- 3D Capture
- Release Notes
- FAQ
Create a Script with Python
This guide describes how to create a simple autosave plugin with Python.
Script structure
Scripts require a single PY file in order to be imported to Sampler. You can save the example script below as a PY file and import it to Sampler.
Example script
The script below automatically creates variations of your material by selecting a new random seed for each layer in the material. This is useful to ensure that your material can be used in a general case instead of relying on specific random seeds.
random_seed_variations.py
import substance_sampler as ssa
from random import randrange
# Get the current asset loaded in the layer stack
my_asset = ssa.get_selected_asset()
# Create a list of all layers of the current asset
my_asset_layers = my_asset.get_layers()
# Go through the layers list
for layer in my_asset_layers:
# Go through all parameters of each layer
for parameter in layer.parameters:
# if the parameter is Random Seed, change is value
if parameter.label == "$randomseed":
parameter.value = randrange(10000)
print(f"Random Seed for layer {layer.name}: {parameter.value}")
The code above includes comments to explain what is happening on each line.
Import the script
Once you've saved the script above as a PY file on your machine, you can import it with Edit > Preferences > Plugins and Scripts. Once imported, a Scripts option will appear in the menu bar alongside File and Edit. From here you can run the script.
You can find out more about managing your scripts here.