I'm trying to set the properties of a Cycles
material, which is linked to a Plane
object, using the API.
So far this is what I've got:
Create a floor plane object:
bpy.ops.mesh.primitive_plane_add(radius=3, view_align=False, enter_editmode=False, location=(0, 0, 0)) my_floor = bpy.data.objects["Plane"]
Create the material for my floor, (I'm assuming it does not already exist):
my_floors_material_name = "Material" #create the materials object my_floors_material_object = bpy.data.materials.new(my_floors_material_name) #Enable 'Use nodes': my_floors_material_object.use_nodes = True
Add a new node type from the list
[types.ShaderNode][1]
. I'd like to choose the equivalent ofnode_groups["Shader Nodetree"].nodes["Anisotropic BSDF"]
:#create the input node shinny_floor_input_node = my_floors_material_nodes.new(type='ShaderNodeBsdfAnisotropic') #create the output node shinny_floor_output_node = my_floors_material_nodes.new(type='ShaderNodeOutputMaterial') #link the input and output nodes, on the node tree of my object my_floors_material_object.node_tree.links.new(shinny_floor_input_node.outputs[0], shinny_floor_output_node.inputs[0]) #this runs and returns bpy.data.node_groups['Shader Nodetree']...NodeLink
Assign the floor material to the floor object:
#assign the material object, to the plane object my_floor.data.materials.append( my_floors_material_object )
Unfortunately it does not work? Here's the floor I want to create, (the shinny one below the statue)
Here's what I get with my current script:
Seems like it should an easy thing to do, but I'm confused? Here's the a link that I used to get started, Control Cycles material nodes and material properties in Python
Thanks a lot for any help!
node_output = nodes.new(type='ShaderNodeOutputMaterial')
, creating shader code: gist.github.com/p2or/… $\endgroup$ – p2or Jun 21 '15 at 13:28