Guest User

Untitled

a guest
May 24th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. def append_approx(data=bpy.data, use_fake_user=False):
  2. in_sockets = [
  3. {'name': 'A'},
  4. {'name': 'B'},
  5. {'name': 'Tolerance',
  6. 'default_value': 0.0001,
  7. 'min_value': 0.0}
  8. ]
  9.  
  10. out_sockets = [
  11. {'name': 'Boolean',
  12. 'min_value': 0.0,
  13. 'max_value': 1.0}
  14. ]
  15.  
  16. # Create group.
  17. approx_group = append_group_node(name='Approx', data=data, use_fake_user=use_fake_user, in_sockets=in_sockets, out_sockets=out_sockets)
  18.  
  19. # Create math nodes.
  20. nodes = approx_group.nodes
  21. subt = append_math_node(nodes, operation='SUBTRACT')
  22. absv = append_math_node(nodes, operation='ABSOLUTE')
  23. gt = append_math_node(nodes, operation='GREATER_THAN')
  24.  
  25. # Link nodes.
  26. links = approx_group.links
  27. links.new(absv.inputs[0], subt.outputs[0])
  28. links.new(gt.inputs[1], absv.outputs[0])
  29.  
  30. # Link to group inputs.
  31. app_input = approx_group.nodes['Group Input']
  32. links.new(subt.inputs[0], app_input.outputs[0])
  33. links.new(subt.inputs[1], app_input.outputs[1])
  34. links.new(gt.inputs[0], app_input.outputs[2])
  35.  
  36. # Link to group outputs.
  37. app_output = approx_group.nodes['Group Output']
  38. links.new(app_output.inputs[0], gt.outputs[0])
  39.  
  40. return approx_group
Add Comment
Please, Sign In to add comment