Copy link to clipboard
Copied
I couldn't find anything about it in the API docs.
thanks,
Reuben
Ok I think we realized the issue. It depends on what the graph type was set to in the sbs file in designer. If it gets set to material, it gets imported in sampler as a material and if it's set as a filter type in designer then it imports to sampler as a filter.
Copy link to clipboard
Copied
Hello,
This is one way of doing it. We will look at adding some specific functions to facilitate the import of SBSAR files in Your Assets section.
Hope it helps.
import substance_sampler as ssa
import os
import time
import shutil
# EDIT THIS FOR YOUR SBSAR
sbsar_path = "C:\\Users\\sampler\\Documents\\assets\\gravel_multicolored.sbsar"
sbsar_label = "Gravel Multicolored" # This is the label of your SBSAR in Sampler
# Construct the path to Sampler's 'Your Assets' folder
path_to_your_assets = os.path.join(os.path.expanduser('~'), "Documents", "Adobe", "Adobe Substance 3D Sampler", "yourAssets")
# Copy the SBSAR to 'Your Assets'
shutil.copy(sbsar_path, os.path.join(path_to_your_assets, os.path.basename(sbsar_path)))
# I create a basic material, but you can use an existing asset
my_asset = ssa.create_asset("MySBSAR", ssa.AssetType.material, select_asset=True)
# This loop waits to make sure the SBSAR has been copied and loaded by Sampler
for _ in range(5):
if ssa.get_materials(sbsar_label):
break
time.sleep(1)
# Get the material and insert it like any of Sampler's starter assets
[my_sbsar_material] = ssa.get_materials(sbsar_label)
my_asset.insert_material(my_sbsar_material, 0, ssa.BlendMode.blend_height)
# Make sure Sampler finishes processing the stack
ssa.wait_for_computation()
Copy link to clipboard
Copied
thanks for your reply Baptiste, that works! is there a way to get the sbsar_label after it's imported into Sampler?
Also is there a difference between importing the sbsar as a material vs as a filter?
Copy link to clipboard
Copied
Hi Baptiste, when we copy the sbsar to the yourAssets folder, for me it appears in Sampler as a material, but for someone else testing our plugin it imports for them as a filter. We want it to appear as a filter but do you know why it's only showing up for me as a material?
Copy link to clipboard
Copied
is there a way to get the sbsar_label after it's imported into Sampler?
I don't think it's possible. The only path could be to import the sbsar in the layer and check the label of layer (by default, it's the sbsar name). Quite a workaround. We look at adding functions to get information on Resources.
Also is there a difference between importing the sbsar as a material vs as a filter?
There is no way to specify that when importing it in the Assets folder but there are two functions when adding an asset to the layer stack:
- insert_material()
- insert_filter()
I would expect that the functions return an error when using insert_material() on a filter asset.
for me it appears in Sampler as a material, but for someone else testing our plugin it imports for them as a filter
This one is really strange. We would need more info (log file, sbsar and script).
Copy link to clipboard
Copied
I can recreate the issue without using a script. Unfortunately I don't see anything being printed out in the log console.
Attached a screen recording where I take the following basic sbsar and copy it to the yourAssets folder. You can see that it appears under the Materials and not Filters for me.
Copy link to clipboard
Copied
Ok I think we realized the issue. It depends on what the graph type was set to in the sbs file in designer. If it gets set to material, it gets imported in sampler as a material and if it's set as a filter type in designer then it imports to sampler as a filter.