Skip to main content
ryangold333
Participant
December 27, 2023
Answered

Image to Material API

  • December 27, 2023
  • 2 replies
  • 407 views

Hi all,

 

I was wondering if it's possible to script an Image to Material pipeline using the Command Line Tools/Automation Toolkit or the Sampler Python API?

 

Thanks,
Ryan

This topic has been closed for replies.
Correct answer DanielMille

Hello, @ryangold333 !
I had the same issue. You can write this functionin your script in pycharm and save it as the .py file. Then import to the Sampler Edit->Preferences-> Plugins and Scripts.

def image_to_material_batch(folder_path):
    for file in os.listdir(folder_path):
        #here you can define texture format to avoid importing unnecessary files
        if file.endswith(".png"):
            image_path_list = [os.path.join(folder_path, file)]
            asset_name = os.path.basename(file).split('.')[0]
            asset = ssa.create_asset(asset_name, ssa.material)
            asset.import_images(image_path_list, 0, ssa.image_to_material_AI_powered, False)

 

2 replies

Participant
December 29, 2023

Of course you will then need to run this function and define your directory. I used project file dir. After importing script to Sampler you just run it from the top menu and it should work.

ryangold333
Participant
January 2, 2024

Hey thanks so much! That's what I needed 🙂

DanielMilleCorrect answer
Participant
December 29, 2023

Hello, @ryangold333 !
I had the same issue. You can write this functionin your script in pycharm and save it as the .py file. Then import to the Sampler Edit->Preferences-> Plugins and Scripts.

def image_to_material_batch(folder_path):
    for file in os.listdir(folder_path):
        #here you can define texture format to avoid importing unnecessary files
        if file.endswith(".png"):
            image_path_list = [os.path.join(folder_path, file)]
            asset_name = os.path.basename(file).split('.')[0]
            asset = ssa.create_asset(asset_name, ssa.material)
            asset.import_images(image_path_list, 0, ssa.image_to_material_AI_powered, False)