__init__.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. # Copyright (c) 2017 Ultimaker B.V.
  2. # Cura is released under the terms of the LGPLv3 or higher.
  3. from . import XmlMaterialProfile
  4. from . import XmlMaterialUpgrader
  5. from UM.MimeTypeDatabase import MimeType, MimeTypeDatabase
  6. upgrader = XmlMaterialUpgrader.XmlMaterialUpgrader()
  7. def getMetaData():
  8. return {
  9. "settings_container": {
  10. "type": "material",
  11. "mimetype": "application/x-ultimaker-material-profile"
  12. },
  13. "version_upgrade": {
  14. ("materials", 1000000): ("materials", 1000007, upgrader.upgradeMaterial),
  15. },
  16. "sources": {
  17. "materials": {
  18. "get_version": upgrader.getXmlVersion,
  19. "location": {"./materials"}
  20. },
  21. }
  22. }
  23. def register(app):
  24. # add Mime type
  25. mime_type = MimeType(
  26. name = "application/x-ultimaker-material-profile",
  27. comment = "Ultimaker Material Profile",
  28. suffixes = [ "xml.fdm_material" ]
  29. )
  30. MimeTypeDatabase.addMimeType(mime_type)
  31. # add upgrade version
  32. from cura.CuraApplication import CuraApplication
  33. from UM.VersionUpgradeManager import VersionUpgradeManager
  34. VersionUpgradeManager.getInstance().registerCurrentVersion(
  35. ("materials", XmlMaterialProfile.XmlMaterialProfile.Version * 1000000 + CuraApplication.SettingVersion),
  36. (CuraApplication.ResourceTypes.MaterialInstanceContainer, "application/x-ultimaker-material-profile")
  37. )
  38. return {"version_upgrade": upgrader,
  39. "settings_container": XmlMaterialProfile.XmlMaterialProfile("default_xml_material_profile"),
  40. }