mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-12 16:28:59 +08:00
Merge pull request #12530 from Ultimaker/CURA-8610_save_required_packages_metadata
[CURA-8610] save required packages metadata
This commit is contained in:
commit
ac32f3b625
@ -62,10 +62,11 @@ class CuraPackageManager(PackageManager):
|
|||||||
for path in Resources.getSecureSearchPaths():
|
for path in Resources.getSecureSearchPaths():
|
||||||
# Secure search paths are install directory paths, if a material is in here it must be bundled.
|
# Secure search paths are install directory paths, if a material is in here it must be bundled.
|
||||||
|
|
||||||
paths = [Path(p) for p in glob.glob(path + '/**/*.xml.fdm_material')]
|
paths = [Path(p) for p in glob.glob(path + '/**/*.xml.fdm_material', recursive=True)]
|
||||||
for material in paths:
|
for material in paths:
|
||||||
if material.name == file_name:
|
if material.name == file_name:
|
||||||
with open(str(material), encoding="utf-8") as f:
|
Logger.info(f"Found bundled material: {material.name}. Located in path: {str(material)}")
|
||||||
|
with open(material, encoding="utf-8") as f:
|
||||||
# Make sure the file we found has the same guid as our material
|
# Make sure the file we found has the same guid as our material
|
||||||
# Parsing this xml would be better but the namespace is needed to search it.
|
# Parsing this xml would be better but the namespace is needed to search it.
|
||||||
parsed_guid = PluginRegistry.getInstance().getPluginObject(
|
parsed_guid = PluginRegistry.getInstance().getPluginObject(
|
||||||
@ -87,11 +88,12 @@ class CuraPackageManager(PackageManager):
|
|||||||
# File with the name we are looking for is not in this directory
|
# File with the name we are looking for is not in this directory
|
||||||
continue
|
continue
|
||||||
|
|
||||||
with open(root + "/" + file_name, encoding="utf-8") as f:
|
with open(os.path.join(root, file_name), encoding="utf-8") as f:
|
||||||
# Make sure the file we found has the same guid as our material
|
# Make sure the file we found has the same guid as our material
|
||||||
# Parsing this xml would be better but the namespace is needed to search it.
|
# Parsing this xml would be better but the namespace is needed to search it.
|
||||||
parsed_guid = PluginRegistry.getInstance().getPluginObject("XmlMaterialProfile").getMetadataFromSerialized(
|
parsed_guid = PluginRegistry.getInstance().getPluginObject("XmlMaterialProfile").getMetadataFromSerialized(
|
||||||
f.read(), "GUID")
|
f.read(), "GUID")
|
||||||
|
|
||||||
if guid == parsed_guid:
|
if guid == parsed_guid:
|
||||||
return package_id
|
return package_id
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ from UM.Logger import Logger
|
|||||||
from UM.Math.Matrix import Matrix
|
from UM.Math.Matrix import Matrix
|
||||||
from UM.Application import Application
|
from UM.Application import Application
|
||||||
from UM.Message import Message
|
from UM.Message import Message
|
||||||
|
from UM.Resources import Resources
|
||||||
from UM.Scene.SceneNode import SceneNode
|
from UM.Scene.SceneNode import SceneNode
|
||||||
|
|
||||||
from cura.CuraApplication import CuraApplication
|
from cura.CuraApplication import CuraApplication
|
||||||
@ -276,6 +277,7 @@ class ThreeMFWriter(MeshWriter):
|
|||||||
|
|
||||||
if not package_data:
|
if not package_data:
|
||||||
# We failed to find the package for this material
|
# We failed to find the package for this material
|
||||||
|
|
||||||
message = Message(catalog.i18nc("@error:material",
|
message = Message(catalog.i18nc("@error:material",
|
||||||
"It was not possible to store material package information in project file: {material}. This project may not open correctly on other systems.".format(material=extruder.getName())),
|
"It was not possible to store material package information in project file: {material}. This project may not open correctly on other systems.".format(material=extruder.getName())),
|
||||||
title=catalog.i18nc("@info:title", "Failed to save material package information"),
|
title=catalog.i18nc("@info:title", "Failed to save material package information"),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user