mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 14:37:29 -06:00
adding dropto buildplate drop per model in 3mf
CURA-10542
This commit is contained in:
parent
fca8d2a751
commit
55e5cd8982
5 changed files with 24 additions and 7 deletions
|
@ -39,7 +39,7 @@ class PlatformPhysics:
|
|||
|
||||
Application.getInstance().getPreferences().addPreference("physics/automatic_push_free", False)
|
||||
Application.getInstance().getPreferences().addPreference("physics/automatic_drop_down", False)
|
||||
self._app_per_model_drop = Application.getInstance().getPreferences().getValue("physics/automatic_drop_down")
|
||||
self._app_per_model_drop = None
|
||||
|
||||
def getAppPerModelDropDown(self):
|
||||
return self._app_per_model_drop
|
||||
|
@ -78,6 +78,14 @@ class PlatformPhysics:
|
|||
# We try to shuffle all the nodes to prevent "locked" situations, where iteration B inverts iteration A.
|
||||
# By shuffling the order of the nodes, this might happen a few times, but at some point it will resolve.
|
||||
random.shuffle(nodes)
|
||||
drop_down = False
|
||||
# drop down in case nodes are asked to drop down from the user from workspaceDialog while opening 3mf
|
||||
if self._app_per_model_drop and (self._app_per_model_drop != app_automatic_drop_down):
|
||||
drop_down = True
|
||||
# drop down in case the user has selected automated drop down preference for 3mf opening
|
||||
if self._app_per_model_drop and app_automatic_drop_down:
|
||||
drop_down= True
|
||||
|
||||
|
||||
for node in nodes:
|
||||
if node is root or not isinstance(node, SceneNode) or node.getBoundingBox() is None:
|
||||
|
@ -88,10 +96,7 @@ class PlatformPhysics:
|
|||
# Move it downwards if bottom is above platform
|
||||
move_vector = Vector()
|
||||
|
||||
# if per model drop is different then app_automatic_drop, in case of 3mf loading when user changes this setting for that model
|
||||
if (self._app_per_model_drop != app_automatic_drop_down):
|
||||
node.setSetting(SceneNodeSettings.AutoDropDown, self._app_per_model_drop)
|
||||
if node.getSetting(SceneNodeSettings.AutoDropDown, self._app_per_model_drop) and not (node.getParent() and node.getParent().callDecoration("isGroup") or node.getParent() != root) and node.isEnabled(): #If an object is grouped, don't move it down
|
||||
if (node.getSetting(SceneNodeSettings.AutoDropDown, app_automatic_drop_down) or drop_down) and not (node.getParent() and node.getParent().callDecoration("isGroup") or node.getParent() != root) and node.isEnabled():
|
||||
z_offset = node.callDecoration("getZOffset") if node.getDecorator(ZOffsetDecorator.ZOffsetDecorator) else 0
|
||||
move_vector = move_vector.set(y=-bbox.bottom + z_offset)
|
||||
|
||||
|
@ -180,7 +185,7 @@ class PlatformPhysics:
|
|||
op.push()
|
||||
|
||||
# setting this drop to model same as app_automatic_drop_down
|
||||
self._app_per_model_drop = app_automatic_drop_down
|
||||
self._app_per_model_drop = None
|
||||
# After moving, we have to evaluate the boundary checks for nodes
|
||||
build_volume.updateNodeBoundaryCheck()
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ from UM.Scene.SceneNode import SceneNode
|
|||
from UM.Scene.SceneNodeDecorator import SceneNodeDecorator # To cast the deepcopy of every decorator back to SceneNodeDecorator.
|
||||
|
||||
import cura.CuraApplication # To get the build plate.
|
||||
from UM.Scene.SceneNodeSettings import SceneNodeSettings
|
||||
from cura.Settings.ExtruderStack import ExtruderStack # For typing.
|
||||
from cura.Settings.SettingOverrideDecorator import SettingOverrideDecorator # For per-object settings.
|
||||
|
||||
|
@ -26,6 +27,7 @@ class CuraSceneNode(SceneNode):
|
|||
self.addDecorator(SettingOverrideDecorator()) # Now we always have a getActiveExtruderPosition, unless explicitly disabled
|
||||
self._outside_buildarea = False
|
||||
self._print_order = 0
|
||||
self._drop_down = Application.getInstance().getPreferences().getValue("physics/automatic_drop_down")
|
||||
|
||||
def setOutsideBuildArea(self, new_value: bool) -> None:
|
||||
self._outside_buildarea = new_value
|
||||
|
@ -41,6 +43,10 @@ class CuraSceneNode(SceneNode):
|
|||
def isOutsideBuildArea(self) -> bool:
|
||||
return self._outside_buildarea or self.callDecoration("getBuildPlateNumber") < 0
|
||||
|
||||
@property
|
||||
def isDropDownEnabled(self) ->bool:
|
||||
return self.getSetting(SceneNodeSettings.AutoDropDown, self._drop_down)
|
||||
|
||||
def isVisible(self) -> bool:
|
||||
return super().isVisible() and self.callDecoration("getBuildPlateNumber") == cura.CuraApplication.CuraApplication.getInstance().getMultiBuildPlateModel().activeBuildPlate
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ from UM.Mesh.MeshReader import MeshReader
|
|||
from UM.MimeTypeDatabase import MimeTypeDatabase, MimeType
|
||||
from UM.Scene.GroupDecorator import GroupDecorator
|
||||
from UM.Scene.SceneNode import SceneNode # For typing.
|
||||
from UM.Scene.SceneNodeSettings import SceneNodeSettings
|
||||
from cura.CuraApplication import CuraApplication
|
||||
from cura.Machines.ContainerTree import ContainerTree
|
||||
from cura.Scene.BuildPlateDecorator import BuildPlateDecorator
|
||||
|
@ -180,6 +181,9 @@ class ThreeMFReader(MeshReader):
|
|||
if key == "print_order":
|
||||
um_node.printOrder = int(setting_value)
|
||||
continue
|
||||
if key =="drop_to_buildplate":
|
||||
um_node.setSetting(SceneNodeSettings.AutoDropDown, eval(setting_value))
|
||||
continue
|
||||
if key in known_setting_keys:
|
||||
setting_container.setProperty(key, "value", setting_value)
|
||||
else:
|
||||
|
|
|
@ -366,6 +366,7 @@ UM.Dialog
|
|||
}
|
||||
function reloadValue()
|
||||
{
|
||||
manager.manager.setDropToBuildPlateForModel(checkDropModels.checked)
|
||||
checkDropModels.checked = UM.Preferences.getValue("physics/automatic_drop_down")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -155,6 +155,7 @@ class ThreeMFWriter(MeshWriter):
|
|||
|
||||
if isinstance(um_node, CuraSceneNode):
|
||||
savitar_node.setSetting("cura:print_order", str(um_node.printOrder))
|
||||
savitar_node.setSetting("cura:drop_to_buildplate", str(um_node.isDropDownEnabled))
|
||||
|
||||
# Store the metadata.
|
||||
for key, value in um_node.metadata.items():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue