Guest User

Untitled

a guest
May 24th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. def append_mag(data=bpy.data, use_fake_user=False):
  2. in_sockets = [
  3. {'name': 'Vector',
  4. 'data_type': 'NodeSocketVector'}
  5. ]
  6.  
  7. out_sockets = [
  8. {'name': 'Magnitude',
  9. 'default_value': 1.0,
  10. 'min_value': 0.0}
  11. ]
  12.  
  13. # Create group.
  14. mag_group = append_group_node(name='Mag', data=data, use_fake_user=use_fake_user, in_sockets=in_sockets, out_sockets=out_sockets)
  15.  
  16. # Create vector math nodes.
  17. nodes = mag_group.nodes
  18. dotp = append_vec_math_node(nodes, operation='DOT_PRODUCT')
  19. sqrt = append_math_node(nodes, operation='POWER', b_default=0.5)
  20.  
  21. # Link nodes.
  22. links = mag_group.links
  23. links.new(sqrt.inputs[0], dotp.outputs[1])
  24.  
  25. # Link to group inputs.
  26. mag_input = mag_group.nodes['Group Input']
  27. links.new(dotp.inputs[0], mag_input.outputs[0])
  28. links.new(dotp.inputs[1], mag_input.outputs[0])
  29.  
  30. # Link to group outputs.
  31. mag_output = mag_group.nodes['Group Output']
  32. links.new(mag_output.inputs[0], sqrt.outputs[0])
  33.  
  34. return mag_group
Add Comment
Please, Sign In to add comment