From aeb7f33c620ebebaca1d2d8e61899bbdd09db2da Mon Sep 17 00:00:00 2001 From: "j.delarago" Date: Wed, 8 Jun 2022 15:25:03 +0200 Subject: [PATCH 1/7] We were previously both scaling down the buildplate and scaling up the disallowed areas of the models with shrinkage compensation. Doing both reduces the max usable area when scaling. The solution is to do only one of these options. Removing the disallowed area works fine when scaling models from their center. However we scale 2 or more models from the buildplate center rather than the model center. This means that the models can go outside the buildplate without it being obvious from the visualization. The better solution is to remove the buildplate x/y scaling and keep the disallowed areas. Removed shrinkage factor build volume scaling on x and y. This information is shown already by scaling the allowed areas around the objects. Kept the bounding box scaling for z. This shows the max height a model can be. The objects disallowed area does not show this information. Also removed scaling on non model disallowed areas on the build plate since this does not need to scale with the build plate anymore. CURA-9271 --- cura/BuildVolume.py | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/cura/BuildVolume.py b/cura/BuildVolume.py index fe607915c1..95674763c5 100755 --- a/cura/BuildVolume.py +++ b/cura/BuildVolume.py @@ -565,8 +565,8 @@ class BuildVolume(SceneNode): self._updateScaleFactor() self._volume_aabb = AxisAlignedBox( - minimum = Vector(min_w, min_h - 1.0, min_d).scale(self._scale_vector), - maximum = Vector(max_w, max_h - self._raft_thickness - self._extra_z_clearance, max_d).scale(self._scale_vector) + minimum = Vector(min_w, min_h - 1.0, min_d), + maximum = Vector(max_w, max_h - self._raft_thickness - self._extra_z_clearance, max_d) ) bed_adhesion_size = self.getEdgeDisallowedSize() @@ -575,8 +575,8 @@ class BuildVolume(SceneNode): # This is probably wrong in all other cases. TODO! # The +1 and -1 is added as there is always a bit of extra room required to work properly. scale_to_max_bounds = AxisAlignedBox( - minimum = Vector(min_w + bed_adhesion_size + 1, min_h, min_d + self._disallowed_area_size - bed_adhesion_size + 1).scale(self._scale_vector), - maximum = Vector(max_w - bed_adhesion_size - 1, max_h - self._raft_thickness - self._extra_z_clearance, max_d - self._disallowed_area_size + bed_adhesion_size - 1).scale(self._scale_vector) + minimum = Vector(min_w + bed_adhesion_size + 1, min_h, min_d + self._disallowed_area_size - bed_adhesion_size + 1), + maximum = Vector(max_w - bed_adhesion_size - 1, max_h - self._raft_thickness - self._extra_z_clearance, max_d - self._disallowed_area_size + bed_adhesion_size - 1) ) self._application.getController().getScene()._maximum_bounds = scale_to_max_bounds # type: ignore @@ -645,7 +645,7 @@ class BuildVolume(SceneNode): for extruder in extruders: extruder.propertyChanged.connect(self._onSettingPropertyChanged) - self._width = self._global_container_stack.getProperty("machine_width", "value") * self._scale_vector.x + self._width = self._global_container_stack.getProperty("machine_width", "value") machine_height = self._global_container_stack.getProperty("machine_height", "value") if self._global_container_stack.getProperty("print_sequence", "value") == "one_at_a_time" and len(self._scene_objects) > 1: self._height = min(self._global_container_stack.getProperty("gantry_height", "value") * self._scale_vector.z, machine_height) @@ -656,7 +656,7 @@ class BuildVolume(SceneNode): else: self._height = self._global_container_stack.getProperty("machine_height", "value") self._build_volume_message.hide() - self._depth = self._global_container_stack.getProperty("machine_depth", "value") * self._scale_vector.y + self._depth = self._global_container_stack.getProperty("machine_depth", "value") self._shape = self._global_container_stack.getProperty("machine_shape", "value") self._updateDisallowedAreas() @@ -752,8 +752,8 @@ class BuildVolume(SceneNode): return self._updateScaleFactor() self._height = self._global_container_stack.getProperty("machine_height", "value") * self._scale_vector.z - self._width = self._global_container_stack.getProperty("machine_width", "value") * self._scale_vector.x - self._depth = self._global_container_stack.getProperty("machine_depth", "value") * self._scale_vector.y + self._width = self._global_container_stack.getProperty("machine_width", "value") + self._depth = self._global_container_stack.getProperty("machine_depth", "value") self._shape = self._global_container_stack.getProperty("machine_shape", "value") def _updateDisallowedAreasAndRebuild(self): @@ -770,14 +770,6 @@ class BuildVolume(SceneNode): self._extra_z_clearance = self._calculateExtraZClearance(ExtruderManager.getInstance().getUsedExtruderStacks()) self.rebuild() - def _scaleAreas(self, result_areas: List[Polygon]) -> None: - if self._global_container_stack is None: - return - for i, polygon in enumerate(result_areas): - result_areas[i] = polygon.scale( - 100.0 / max(100.0, self._global_container_stack.getProperty("material_shrinkage_percentage_xy", "value")) - ) - def _updateDisallowedAreas(self) -> None: if not self._global_container_stack: return @@ -833,11 +825,9 @@ class BuildVolume(SceneNode): self._disallowed_areas = [] for extruder_id in result_areas: - self._scaleAreas(result_areas[extruder_id]) self._disallowed_areas.extend(result_areas[extruder_id]) self._disallowed_areas_no_brim = [] for extruder_id in result_areas_no_brim: - self._scaleAreas(result_areas_no_brim[extruder_id]) self._disallowed_areas_no_brim.extend(result_areas_no_brim[extruder_id]) def _computeDisallowedAreasPrinted(self, used_extruders): From dd3abf7ff08d670e37bace267c93aecdb11ba4c2 Mon Sep 17 00:00:00 2001 From: "j.delarago" Date: Wed, 22 Jun 2022 14:05:56 +0200 Subject: [PATCH 2/7] Add check for empty material instance containers before trying to fetch material metadata. This fixes failing to save a project on a printer with no materials (UM2 for example). CURA-9412 --- plugins/3MFWriter/ThreeMFWriter.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/3MFWriter/ThreeMFWriter.py b/plugins/3MFWriter/ThreeMFWriter.py index c507703823..3bb1d44e01 100644 --- a/plugins/3MFWriter/ThreeMFWriter.py +++ b/plugins/3MFWriter/ThreeMFWriter.py @@ -12,6 +12,7 @@ from UM.Application import Application from UM.Message import Message from UM.Resources import Resources from UM.Scene.SceneNode import SceneNode +from UM.Settings.EmptyInstanceContainer import EmptyInstanceContainer from cura.CuraApplication import CuraApplication from cura.CuraPackageManager import CuraPackageManager @@ -268,6 +269,10 @@ class ThreeMFWriter(MeshWriter): # Don't export materials not in use continue + if type(extruder.material) is EmptyInstanceContainer: + # This is an empty material container, no material to export + continue + if package_manager.isMaterialBundled(extruder.material.getFileName(), extruder.material.getMetaDataEntry("GUID")): # Don't export bundled materials continue From 9aaf59ae8634a04fa3d0b45f7b37ca3ffdcfac1c Mon Sep 17 00:00:00 2001 From: "j.delarago" Date: Fri, 24 Jun 2022 14:29:50 +0200 Subject: [PATCH 3/7] Suggested changes CURA-9412 --- plugins/3MFWriter/ThreeMFWriter.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/3MFWriter/ThreeMFWriter.py b/plugins/3MFWriter/ThreeMFWriter.py index 3bb1d44e01..7dd5dac8a3 100644 --- a/plugins/3MFWriter/ThreeMFWriter.py +++ b/plugins/3MFWriter/ThreeMFWriter.py @@ -12,6 +12,7 @@ from UM.Application import Application from UM.Message import Message from UM.Resources import Resources from UM.Scene.SceneNode import SceneNode +from UM.Settings.ContainerRegistry import ContainerRegistry from UM.Settings.EmptyInstanceContainer import EmptyInstanceContainer from cura.CuraApplication import CuraApplication @@ -269,7 +270,7 @@ class ThreeMFWriter(MeshWriter): # Don't export materials not in use continue - if type(extruder.material) is EmptyInstanceContainer: + if isinstance(extruder.material, type(ContainerRegistry.getInstance().getEmptyInstanceContainer())): # This is an empty material container, no material to export continue From 2c074fb7a3e24731722e937a27f03b5ac8b26365 Mon Sep 17 00:00:00 2001 From: "c.lamboo" Date: Fri, 24 Jun 2022 14:52:42 +0200 Subject: [PATCH 4/7] Don't show scary error message when saving custom file CURA-9414 --- plugins/3MFWriter/ThreeMFWriter.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/plugins/3MFWriter/ThreeMFWriter.py b/plugins/3MFWriter/ThreeMFWriter.py index c507703823..d97e7d4ac7 100644 --- a/plugins/3MFWriter/ThreeMFWriter.py +++ b/plugins/3MFWriter/ThreeMFWriter.py @@ -275,14 +275,8 @@ class ThreeMFWriter(MeshWriter): package_id = package_manager.getMaterialFilePackageId(extruder.material.getFileName(), extruder.material.getMetaDataEntry("GUID")) package_data = package_manager.getInstalledPackageInfo(package_id) + # We failed to find the package for this material if not package_data: - # We failed to find the package for this 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())), - title=catalog.i18nc("@info:title", "Failed to save material package information"), - message_type=Message.MessageType.WARNING) - message.show() continue material_metadata = {"id": package_id, From 41cc78af1a0687523ec6ecadddea9da1e7120fe5 Mon Sep 17 00:00:00 2001 From: "j.delarago" Date: Fri, 24 Jun 2022 15:00:42 +0200 Subject: [PATCH 5/7] Add at a minumum a very small border around the edges of the build plate. Otherwise models with shrinkage compensation (or any model with disallowed areas around it) can be placed so that the output model is off the build plate. CURA-9271 --- cura/BuildVolume.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cura/BuildVolume.py b/cura/BuildVolume.py index 95674763c5..776d92a1f6 100755 --- a/cura/BuildVolume.py +++ b/cura/BuildVolume.py @@ -983,6 +983,9 @@ class BuildVolume(SceneNode): half_machine_width = self._global_container_stack.getProperty("machine_width", "value") / 2 half_machine_depth = self._global_container_stack.getProperty("machine_depth", "value") / 2 + # We need at a minimum a very small border around the edge so that models can't go off the build plate + border_size = max(border_size, 0.1) + if self._shape != "elliptic": if border_size - left_unreachable_border > 0: result[extruder_id].append(Polygon(numpy.array([ From 1872e5484279918232600f984173ceade9c37266 Mon Sep 17 00:00:00 2001 From: Remco Burema Date: Tue, 28 Jun 2022 13:06:59 +0200 Subject: [PATCH 6/7] Message might be good for debugging. Maybe at some point someone will ask wjy they don't get a message. part of CURA-9414 --- plugins/3MFWriter/ThreeMFWriter.py | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/3MFWriter/ThreeMFWriter.py b/plugins/3MFWriter/ThreeMFWriter.py index d97e7d4ac7..888779af91 100644 --- a/plugins/3MFWriter/ThreeMFWriter.py +++ b/plugins/3MFWriter/ThreeMFWriter.py @@ -277,6 +277,7 @@ class ThreeMFWriter(MeshWriter): # We failed to find the package for this material if not package_data: + Logger.info(f"Could not find package for material in extruder {extruder.id}, skipping.") continue material_metadata = {"id": package_id, From f241638890ac1076546f01593c5ccb3253812d51 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Tue, 28 Jun 2022 17:52:51 +0200 Subject: [PATCH 7/7] Add resolve function to Remove Raft Inside Corners That way, an extruder profile can say that they want this. If any extruder needs this setting enabled, it will be enabled for the whole print. Done as a 5 minute fix. --- resources/definitions/fdmprinter.def.json | 1 + 1 file changed, 1 insertion(+) diff --git a/resources/definitions/fdmprinter.def.json b/resources/definitions/fdmprinter.def.json index c34216572d..872101154c 100644 --- a/resources/definitions/fdmprinter.def.json +++ b/resources/definitions/fdmprinter.def.json @@ -8053,6 +8053,7 @@ "description": "Remove inside corners from the raft, causing the raft to become convex.", "type": "bool", "default_value": false, + "resolve": "any(extruderValues('raft_remove_inside_corners'))", "enabled": "resolveOrValue('adhesion_type') == 'raft'", "settable_per_mesh": false, "settable_per_extruder": false