My script is not functioning as I would like. I am appending a material from a file and the material is not adding to the material list.
Second I am trying to change the generated ellipsoid to a different material. I believe this code is simply changing the name and not changing to the saved material.
I can get around the first error by manually going to append and finding the file in my downloads.
Thank you for any support. S
import bpy mat = 'Gold' path = "C:/Users/ME/Downloads/78-gold.blend\\Material\\" #ERR1 bpy.ops.wm.append(filename = mat, directory = path) import numpy as np loc_scale = 0.05 anisotropy = 10 for k in range(10): for j in range(10): for i in range(4): context = bpy.context scene = context.scene # add a sphere offsetx,offsety, offsetz = [0.5 , 0.5, 0.5] - np.random.random(3) bpy.ops.mesh.primitive_uv_sphere_add(location=(2 - k + offsetx, 2- j + offsety, -.5+ i + offsetz), rotation=( .1 - .2*np.random.random(), .1-.2*np.random.random(), .1-.2*np.random.random())) sphere = scene.objects.active # scale to (rx, ry, rz) of ellipsoid sphere.scale = (loc_scale, loc_scale, anisotropy*loc_scale) #apply scale bpy.ops.object.transform_apply(scale=True) #ERR2 bpy.context.object.active_material.name = "gold" activeObject = bpy.context.active_object #Set active object to variable