TestGraphAPIs.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. """
  2. Copyright (c) Contributors to the Open 3D Engine Project.
  3. For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. SPDX-License-Identifier: Apache-2.0 OR MIT
  5. """
  6. import azlmbr.atom
  7. import azlmbr.atomtools
  8. import azlmbr.atomtools as atomtools
  9. import azlmbr.bus
  10. import azlmbr.bus as bus
  11. import azlmbr.editor.graph as graph
  12. import azlmbr.math as math
  13. import azlmbr.paths
  14. import azlmbr.std
  15. import collections
  16. import os
  17. import pathlib
  18. import random
  19. import sys
  20. import time
  21. def main():
  22. test_document_id = atomtools.AtomToolsDocumentSystemRequestBus(bus.Broadcast, "CreateDocumentFromTypeName", "Material Graph")
  23. print(f"{test_document_id.ToString()}")
  24. test_graph = atomtools.GraphDocumentRequestBus(bus.Event, "GetGraph", test_document_id)
  25. print(f"{test_graph=}")
  26. print(f"{test_graph.invoke('GetSystemName')}")
  27. test_graph_id = atomtools.GraphDocumentRequestBus(bus.Event, "GetGraphId", test_document_id)
  28. print(f"{test_graph_id.ToString()}")
  29. test_output_node = atomtools.DynamicNodeManagerRequestBus(bus.Broadcast, "CreateNodeByName", test_graph, "Standard PBR")
  30. print(f"{test_output_node=}")
  31. print(f"{test_output_node.typename}")
  32. print(f"{test_output_node.invoke('GetId')}")
  33. graph.GraphControllerRequestBus(bus.Event, "AddNode", test_graph_id, test_output_node, math.Vector2(0.0, 0.0))
  34. test_output_node_id = graph.GraphControllerRequestBus(bus.Event, "GetNodeIdByNode", test_graph_id, test_output_node)
  35. print(f"{test_output_node_id.ToString()}")
  36. if __name__ == "__main__":
  37. main()