Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How can I control Substance 3D plugin for Blender via Blender Python API?

Community Beginner ,
Feb 07, 2024 Feb 07, 2024

I want to load a sbsar file and attach the material to any objects using Python API.

 

Like following pseudo codes,

 

import bpy
import substance3d

path = '<path/to/sbsar_file>'
substance3d.obj.load(path)
material = bpy.context.materials['name_of_sbsar']
object = bpy.context.selected_objects[0]
object.data.materials.append(material)

 

I have used Blender 4.0 and new Substance 3D Plugin for Blender.

 

Does anyone have any good advices?

TOPICS
Blender , Question
454
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 07, 2024 Feb 07, 2024

Sorry, that wasn't hard.

 

import bpy
bpy.ops.substance.load_sbsar(filepath="<path>/hoge.sbsar", files=[{"name":"hoge.sbsar"}], directory="<path>")
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Feb 07, 2024 Feb 07, 2024

Thanks for sharing this! We'll capture it in our documentation 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 08, 2024 Feb 08, 2024
LATEST

But.... It wasn't that easy, again.

 

Addon initializer and SBSAR loading function are executed on another thread.

I want to attach the material which is created from sbsar file to any objects, but materials are still empy after loading a SBSAR file.

I do not know how to wait these threads....

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines