internal_containers.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. from .node_container_common import *
  2. from bpy.types import Node
  3. from .base_definitions import MantisNode
  4. from uuid import uuid4
  5. class DummyNode(MantisNode):
  6. def __init__(self, signature, base_tree, prototype = None, natural_signature=None):
  7. super().__init__(signature, base_tree)
  8. self.prototype = prototype
  9. self.node_type = 'DUMMY'
  10. self.prepared = True
  11. if prototype.bl_idname in ["MantisSchemaGroup"]:
  12. self.node_type = 'DUMMY_SCHEMA'
  13. self.prepared = False
  14. self.uuid = uuid4()
  15. if prototype:
  16. for sock in prototype.inputs:
  17. if sock.identifier == "__extend__" or sock.name == "__extend__":
  18. continue
  19. self.inputs[sock.identifier] = NodeSocket(is_input = True, name = sock.identifier, node = self)
  20. for sock in prototype.outputs:
  21. if sock.identifier == "__extend__" or sock.name == "__extend__":
  22. continue
  23. self.outputs[sock.identifier] = NodeSocket(is_input = False, name = sock.identifier, node = self)
  24. self.parameters[sock.identifier]=None
  25. # keep track of the "natural signature" of Schema nodes - so that they are unambiguous
  26. self.natural_signature=self.signature
  27. if natural_signature:
  28. self.natural_signature=natural_signature
  29. # This is necessary for Schema to work if there are multiple Schema nodes using the same Schema tree.
  30. # this is ugly and I hate it.
  31. class NoOpNode(MantisNode):
  32. def __init__(self, signature, base_tree):
  33. super().__init__(signature, base_tree)
  34. self.inputs.init_sockets(["Input"])
  35. self.outputs.init_sockets(["Output"])
  36. self.init_parameters()
  37. self.set_traverse([("Input", "Output")])
  38. self.node_type = 'UTILITY'
  39. self.prepared = True
  40. self.executed = True
  41. # this node is useful for me to insert in the tree and use for debugging especially connections.