material_editor_utils.py 1.3 KB

123456789101112131415161718192021222324252627282930313233
  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.math as math
  7. import azlmbr.bus as bus
  8. import azlmbr.materialeditor as materialeditor
  9. def get_property(document_id: math.Uuid, property_name: str) -> any:
  10. """
  11. Gets a property value for a given document_id and property name.
  12. :param document_id: The UUID of a given document file.
  13. :param property_name: The property name to search for the property value.
  14. :return: property value or invalid value if the document is not open or the property_name can't be found
  15. """
  16. return materialeditor.MaterialDocumentRequestBus(bus.Event, "GetPropertyValue", document_id, property_name)
  17. def set_property(
  18. document_id: math.Uuid, property_name: str, value: math.Uuid or int or float or math.Color) -> None:
  19. """
  20. Sets a property value for a given document_id, property_name, and value.
  21. :param document_id: The UUID of a given document file.
  22. :param property_name: The property name to search for the property value.
  23. :param value: The value to set on the property.
  24. :return: None
  25. """
  26. materialeditor.MaterialDocumentRequestBus(bus.Event, "SetPropertyValue", document_id, property_name, value)