mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 14:37:29 -06:00
Added Support Eraser Plugin
This is the first draft of the Support Eraser tool. The plugin creates a cube mesh which has the `anti_overhang_mesh` decorator causing it to block the creation of support material for overhangs within its volume. This distinction is necessary to avoid confusing this behavior from actually erasing a _portion_ of a support structure. Some (non-necessary) improvements could be made such as: - Better graphical style - Discussion of whether the cube should be able to pass through the build plate or not - Possible improvements to the tool's icon - Placing the cube at a cursor click location
This commit is contained in:
parent
36eded925c
commit
e1da097970
4 changed files with 107 additions and 0 deletions
68
plugins/SupportEraser/SupportEraser.py
Normal file
68
plugins/SupportEraser/SupportEraser.py
Normal file
|
@ -0,0 +1,68 @@
|
|||
from UM.Tool import Tool
|
||||
from PyQt5.QtCore import Qt, QUrl
|
||||
from UM.Application import Application
|
||||
from UM.Event import Event
|
||||
from UM.Mesh.MeshBuilder import MeshBuilder
|
||||
from UM.Operations.AddSceneNodeOperation import AddSceneNodeOperation
|
||||
from UM.Settings.SettingInstance import SettingInstance
|
||||
from cura.Scene.CuraSceneNode import CuraSceneNode
|
||||
from cura.Scene.SliceableObjectDecorator import SliceableObjectDecorator
|
||||
from cura.Scene.BuildPlateDecorator import BuildPlateDecorator
|
||||
from cura.Settings.SettingOverrideDecorator import SettingOverrideDecorator
|
||||
|
||||
import os
|
||||
import os.path
|
||||
|
||||
class SupportEraser(Tool):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self._shortcut_key = Qt.Key_G
|
||||
self._controller = Application.getInstance().getController()
|
||||
|
||||
def event(self, event):
|
||||
super().event(event)
|
||||
|
||||
if event.type == Event.ToolActivateEvent:
|
||||
|
||||
# Load the remover mesh:
|
||||
self._createEraserMesh()
|
||||
|
||||
# After we load the mesh, deactivate the tool again:
|
||||
self.getController().setActiveTool(None)
|
||||
|
||||
def _createEraserMesh(self):
|
||||
# Selection.clear()
|
||||
|
||||
node = CuraSceneNode()
|
||||
|
||||
node.setName("Eraser")
|
||||
node.setSelectable(True)
|
||||
mesh = MeshBuilder()
|
||||
mesh.addCube(10,10,10)
|
||||
node.setMeshData(mesh.build())
|
||||
|
||||
active_build_plate = Application.getInstance().getBuildPlateModel().activeBuildPlate
|
||||
|
||||
node.addDecorator(SettingOverrideDecorator())
|
||||
node.addDecorator(BuildPlateDecorator(active_build_plate))
|
||||
node.addDecorator(SliceableObjectDecorator())
|
||||
|
||||
stack = node.callDecoration("getStack") #Don't try to get the active extruder since it may be None anyway.
|
||||
if not stack:
|
||||
node.addDecorator(SettingOverrideDecorator())
|
||||
stack = node.callDecoration("getStack")
|
||||
|
||||
print(stack)
|
||||
settings = stack.getTop()
|
||||
|
||||
if not (settings.getInstance("anti_overhang_mesh") and settings.getProperty("anti_overhang_mesh", "value")):
|
||||
definition = stack.getSettingDefinition("anti_overhang_mesh")
|
||||
new_instance = SettingInstance(definition, settings)
|
||||
new_instance.setProperty("value", True)
|
||||
new_instance.resetState() # Ensure that the state is not seen as a user state.
|
||||
settings.addInstance(new_instance)
|
||||
|
||||
scene = self._controller.getScene()
|
||||
op = AddSceneNodeOperation(node, scene.getRoot())
|
||||
op.push()
|
||||
Application.getInstance().getController().getScene().sceneChanged.emit(node)
|
Loading…
Add table
Add a link
Reference in a new issue