Changing material of the object via blendluxcore python script
Posted: Fri Jan 11, 2019 9:14 am
Hi,
I want to change the material of an object (for example of a Cube/Plane) in Blender using Blendluxcore, and I want to be able to assign the material via python script.
I found the available materials in blender, I select an object -> Material -> Node Tree Presets -> Matte, Glossy etc.
I also found preset function:
bpy.ops.luxcore.preset_material(preset='Matte')
But when typing it in console it returns:
Traceback (most recent call last):
File "<blender_console>", line 1, in <module>
File "C:\Program Files\Blender Foundation\Blender\2.79\scripts\modules\bpy\ops.py", line 189, in __call__
ret = op_call(self.idname_py(), None, kw)
RuntimeError: Error: Traceback (most recent call last):
File "C:\Users\pro\AppData\Roaming\Blender Foundation\Blender\2.79\scripts\addons\BlendLuxCore\operators\node_tree_presets.py", line 53, in execute
mat = context.material
AttributeError: 'Context' object has no attribute 'material'
location: C:\Program Files\Blender Foundation\Blender\2.79\scripts\modules\bpy\ops.py:189
So my question is simple - how can I achieve to select material for a selected object via python in Blender.
Thank you very much for your time answering my question!
I want to change the material of an object (for example of a Cube/Plane) in Blender using Blendluxcore, and I want to be able to assign the material via python script.
I found the available materials in blender, I select an object -> Material -> Node Tree Presets -> Matte, Glossy etc.
I also found preset function:
bpy.ops.luxcore.preset_material(preset='Matte')
But when typing it in console it returns:
Traceback (most recent call last):
File "<blender_console>", line 1, in <module>
File "C:\Program Files\Blender Foundation\Blender\2.79\scripts\modules\bpy\ops.py", line 189, in __call__
ret = op_call(self.idname_py(), None, kw)
RuntimeError: Error: Traceback (most recent call last):
File "C:\Users\pro\AppData\Roaming\Blender Foundation\Blender\2.79\scripts\addons\BlendLuxCore\operators\node_tree_presets.py", line 53, in execute
mat = context.material
AttributeError: 'Context' object has no attribute 'material'
location: C:\Program Files\Blender Foundation\Blender\2.79\scripts\modules\bpy\ops.py:189
So my question is simple - how can I achieve to select material for a selected object via python in Blender.
Thank you very much for your time answering my question!