__init__.py 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. # Copyright (c) 2017 Ultimaker B.V.
  2. # Cura is released under the terms of the AGPLv3 or higher.
  3. from . import XmlMaterialProfile
  4. from . import XmlMaterialUpgrader
  5. from UM.MimeTypeDatabase import MimeType, MimeTypeDatabase
  6. from UM.i18n import i18nCatalog
  7. catalog = i18nCatalog("cura")
  8. upgrader = XmlMaterialUpgrader.XmlMaterialUpgrader()
  9. def getMetaData():
  10. return {
  11. "plugin": {
  12. "name": catalog.i18nc("@label", "Material Profiles"),
  13. "author": "Ultimaker",
  14. "version": "1.0",
  15. "description": catalog.i18nc("@info:whatsthis", "Provides capabilities to read and write XML-based material profiles."),
  16. "api": 3
  17. },
  18. "settings_container": {
  19. "type": "material",
  20. "mimetype": "application/x-ultimaker-material-profile"
  21. },
  22. "version_upgrade": {
  23. ("materials", 1000000): ("materials", 1000001, upgrader.upgradeMaterial),
  24. },
  25. "sources": {
  26. "materials": {
  27. "get_version": upgrader.getXmlVersion,
  28. "location": {"./materials"}
  29. },
  30. }
  31. }
  32. def register(app):
  33. # add Mime type
  34. mime_type = MimeType(
  35. name = "application/x-ultimaker-material-profile",
  36. comment = "Ultimaker Material Profile",
  37. suffixes = [ "xml.fdm_material" ]
  38. )
  39. MimeTypeDatabase.addMimeType(mime_type)
  40. # add upgrade version
  41. from cura.CuraApplication import CuraApplication
  42. from UM.VersionUpgradeManager import VersionUpgradeManager
  43. VersionUpgradeManager.getInstance().registerCurrentVersion(
  44. ("materials", XmlMaterialProfile.XmlMaterialProfile.Version * 1000000 + CuraApplication.SettingVersion),
  45. (CuraApplication.ResourceTypes.MaterialInstanceContainer, "application/x-ultimaker-material-profile")
  46. )
  47. return {"version_upgrade": upgrader,
  48. "settings_container": XmlMaterialProfile.XmlMaterialProfile("default_xml_material_profile"),
  49. }