DarkfallBlender

nodo_de_grupo_personalizado

Mar 11th, 2020
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.71 KB | None | 0 0
  1. import bpy
  2.  
  3. # create a group
  4. # crear un grupo
  5. test_group = bpy.data.node_groups.new('testGroup', 'ShaderNodeTree')
  6.  
  7. # create group inputs
  8. # crear entradas de grupo
  9. group_inputs = test_group.nodes.new('NodeGroupInput')
  10. group_inputs.location = (-350,0)
  11. test_group.inputs.new('NodeSocketFloat','in_to_greater')
  12. test_group.inputs.new('NodeSocketFloat','in_to_less')
  13.  
  14. # create group outputs
  15. # crear salidas grupales
  16. group_outputs = test_group.nodes.new('NodeGroupOutput')
  17. group_outputs.location = (300,0)
  18. test_group.outputs.new('NodeSocketFloat','out_result')
  19.  
  20. # create nodes to be inside of the group
  21. # crear nodos para estar dentro del grupo
  22. # you can delete these nodes or change them to be the nodes you want
  23. # puede eliminar estos nodos o cambiarlos para que sean los nodos que desee
  24. node_add = test_group.nodes.new('ShaderNodeMath')
  25. node_add.operation = 'ADD'
  26. node_add.location = (100,0)
  27.  
  28. node_greater = test_group.nodes.new('ShaderNodeMath')
  29. node_greater.operation = 'GREATER_THAN'
  30. node_greater.label = 'greater'
  31. node_greater.location = (-100,100)
  32.  
  33. node_less = test_group.nodes.new('ShaderNodeMath')
  34. node_less.operation = 'LESS_THAN'
  35. node_less.label = 'less'
  36. node_less.location = (-100,-100)
  37.  
  38. # link the nodes together
  39. # enlazar los nodos juntos
  40. test_group.links.new(node_add.inputs[0], node_greater.outputs[0])
  41. test_group.links.new(node_add.inputs[1], node_less.outputs[0])
  42.  
  43. # link the inputs
  44. # vincular las entradas
  45. test_group.links.new(group_inputs.outputs['in_to_greater'], node_greater.inputs[0])
  46. test_group.links.new(group_inputs.outputs['in_to_less'], node_less.inputs[0])
  47.  
  48. # link the output
  49. # vincular la salida
  50. test_group.links.new(node_add.outputs[0], group_outputs.inputs['out_result'])
Advertisement
Add Comment
Please, Sign In to add comment