import bpy tree = bpy.data.materials['Material'].node_tree def create_nodegroup(): # create node group my_new_Group = bpy.data.node_groups.new('My_New_Group', 'ShaderNodeTree') # input mngInputs = my_new_Group.nodes.new('NodeGroupInput') mngInputs.location = (0,0) my_new_Group.inputs.new('NodeSocketFloat','my scale input') # output mngOutputs = my_new_Group.nodes.new('NodeGroupOutput') mngOutputs.location = (500,0) my_new_Group.outputs.new('NodeSocketFloat','my float output') my_new_Group.outputs.new('NodeSocketColor','my color output') # node in nodegroup texnode = my_new_Group.nodes.new('ShaderNodeTexWave') texnode.location = (200,0) # connect nodes my_new_Group.links.new(mngInputs.outputs[0],texnode.inputs[0]) my_new_Group.links.new(texnode.outputs['Color'],mngOutputs.inputs['my color output']) return my_new_Group ################################################################ ###################### Add New Node Group ###################### ################################################################ groupnode = tree.nodes.new(type='ShaderNodeGroup') groupnode.node_tree = create_nodegroup()
なおNode Groupから出るには[Tab]キーを押す