Skip to main content
Inspiring
April 11, 2024
Answered

is there a way to bring in an sbsar to Sampler with the python api?

  • April 11, 2024
  • 1 reply
  • 1151 views

I couldn't find anything about it in the API docs. 

 

thanks,

Reuben

This topic has been closed for replies.
Correct answer Reuben5C64

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.


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.

1 reply

Baptiste_Substance_3D
Community Manager
Community Manager
April 11, 2024

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()
Inspiring
April 29, 2024

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?

Reuben5C64AuthorCorrect answer
Inspiring
May 3, 2024

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.


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.