5,337
edits
Line 81: | Line 81: | ||
# Add material to an object | # Add material to an object | ||
my_object.data.materials.append(my_material) | my_object.data.materials.append(my_material) | ||
</syntaxhighlight> | |||
====Images==== | |||
<syntaxhighlight lang="python"> | |||
# Add an image | |||
image_bpy = bpy.data.images.new("my_image", width=width, height=height, alpha=(channels==4), float_buffer=False) | |||
image_bpy.pixels = image_np.ravel() | |||
my_material.node_tree.links.new(image_bpy.outputs['Color'], my_bsdf.inputs['Base Color']) | |||
</syntaxhighlight> | </syntaxhighlight> | ||