UpgradeAllMaterials.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  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 sys
  7. import os
  8. import azlmbr.bus
  9. import azlmbr.paths
  10. import collections
  11. def main():
  12. paths = azlmbr.atomtools.util.GetPathsInSourceFoldersMatchingExtension('material')
  13. for path in paths.copy():
  14. if 'cache' in path.lower():
  15. paths.remove(path)
  16. documentId = azlmbr.atomtools.AtomToolsDocumentSystemRequestBus(azlmbr.bus.Broadcast, 'CreateDocumentFromTypeName', 'Material')
  17. if documentId.IsNull():
  18. print("The material document could not be opened")
  19. return
  20. for path in paths:
  21. if azlmbr.atomtools.util.IsDocumentPathEditable(path):
  22. if azlmbr.atomtools.AtomToolsDocumentRequestBus(azlmbr.bus.Event, 'Open', documentId, path):
  23. azlmbr.atomtools.AtomToolsDocumentRequestBus(azlmbr.bus.Event, 'Save', documentId)
  24. azlmbr.atomtools.AtomToolsDocumentSystemRequestBus(azlmbr.bus.Broadcast, 'DestroyDocument', documentId)
  25. if __name__ == "__main__":
  26. main()