Path: Make a command and icon to toggle op active status
This commit is contained in:
@@ -76,7 +76,7 @@ class PathWorkbench (Workbench):
|
||||
|
||||
# build commands list
|
||||
projcmdlist = ["Path_Job", "Path_Post"]
|
||||
toolcmdlist = ["Path_Inspect", "Path_Simulator", "Path_ToolLibraryEdit", "Path_SelectLoop"]
|
||||
toolcmdlist = ["Path_Inspect", "Path_Simulator", "Path_ToolLibraryEdit", "Path_SelectLoop", "Path_OpActiveToggle"]
|
||||
prepcmdlist = ["Path_Fixture", "Path_Comment", "Path_Stop", "Path_Custom"]
|
||||
twodopcmdlist = ["Path_Contour", "Path_Profile_Faces", "Path_Profile_Edges", "Path_Pocket_Shape", "Path_Drilling", "Path_MillFace", "Path_Helix", "Path_Adaptive" ]
|
||||
threedopcmdlist = ["Path_Pocket_3D"]
|
||||
@@ -151,7 +151,7 @@ class PathWorkbench (Workbench):
|
||||
if "Job" in selectedName:
|
||||
self.appendContextMenu("", ["Path_ExportTemplate"])
|
||||
if isinstance (obj.Proxy, PathScripts.PathOp.ObjectOp):
|
||||
self.appendContextMenu("", ["Path_OperationCopy"])
|
||||
self.appendContextMenu("", ["Path_OperationCopy", "Path_OpActiveToggle"])
|
||||
if obj.isDerivedFrom("Path::Feature"):
|
||||
if "Profile" in selectedName or "Contour" in selectedName or "Dressup" in selectedName:
|
||||
self.appendContextMenu("", "Separator")
|
||||
@@ -164,6 +164,6 @@ Gui.addWorkbench(PathWorkbench())
|
||||
|
||||
FreeCAD.addImportType(
|
||||
"GCode (*.nc *.gc *.ncc *.ngc *.cnc *.tap *.gcode)", "PathGui")
|
||||
FreeCAD.addExportType(
|
||||
"GCode (*.nc *.gc *.ncc *.ngc *.cnc *.tap *.gcode)", "PathGui")
|
||||
# FreeCAD.addExportType(
|
||||
# "GCode (*.nc *.gc *.ncc *.ngc *.cnc *.tap *.gcode)", "PathGui")
|
||||
|
||||
|
||||
@@ -78,9 +78,9 @@ class _CommandSelectLoop:
|
||||
PathLog.error(exc)
|
||||
traceback.print_exc(exc)
|
||||
return False
|
||||
|
||||
|
||||
def Activated(self):
|
||||
from PathScripts.PathUtils import loopdetect
|
||||
#from PathScripts.PathUtils import loopdetect
|
||||
from PathScripts.PathUtils import horizontalEdgeLoop
|
||||
from PathScripts.PathUtils import horizontalFaceLoop
|
||||
sel = FreeCADGui.Selection.getSelectionEx()[0]
|
||||
@@ -120,6 +120,31 @@ class _CommandSelectLoop:
|
||||
if FreeCAD.GuiUp:
|
||||
FreeCADGui.addCommand('Path_SelectLoop', _CommandSelectLoop())
|
||||
|
||||
class _ToggleOperation:
|
||||
"command definition to toggle Operation Active state"
|
||||
def GetResources(self):
|
||||
return {'Pixmap': 'Path-OpActive',
|
||||
'MenuText': QtCore.QT_TRANSLATE_NOOP("Path_OpActiveToggle", "Toggle the Active State of the Operation"),
|
||||
'Accel': "P, X",
|
||||
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Path_OpActiveToggle", "Toggle the Active State of the Operation"),
|
||||
'CmdType': "ForEdit"}
|
||||
|
||||
def IsActive(self):
|
||||
if bool(FreeCADGui.Selection.getSelection()) is False:
|
||||
return False
|
||||
try:
|
||||
obj = FreeCADGui.Selection.getSelectionEx()[0].Object
|
||||
return isinstance(obj.Proxy, PathScripts.PathOp.ObjectOp)
|
||||
except:
|
||||
return False
|
||||
|
||||
def Activated(self):
|
||||
obj = FreeCADGui.Selection.getSelectionEx()[0].Object
|
||||
obj.Active = not(obj.Active)
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
|
||||
if FreeCAD.GuiUp:
|
||||
FreeCADGui.addCommand('Path_OpActiveToggle', _ToggleOperation())
|
||||
|
||||
class _CopyOperation:
|
||||
"the Path Copy Operation command definition"
|
||||
|
||||
Reference in New Issue
Block a user