#from easybpy import *
import bpy
mat = bpy.context.object.active_material
nodes = mat.node_tree.nodes
#clear all node
nodes.clear()
#create node
imageTex = nodes.new(type="ShaderNodeTexImage")
bsdf = nodes.new(type='ShaderNodeBsdfPrincipled')
node_output = nodes.new(type='ShaderNodeOutputMaterial')
#setup image
print(imageTex)
imageTex.image = bpy.data.images[0]
#link together
links = mat.node_tree.links
link_image_bsdf = links.new(imageTex.outputs[0], bsdf.inputs[0])
link_bsdf_out = links.new(bsdf.outputs[0], node_output.inputs[0])
网友评论