CAM: fixes bug with op creation/cancelation (#25800)

This commit is contained in:
sliptonic
2025-12-01 10:59:49 -06:00
committed by GitHub
parent cb9c0ccd7f
commit db65e44bca
3 changed files with 22 additions and 6 deletions

View File

@@ -550,7 +550,10 @@ class ObjectOp(object):
job = self.job
else:
job = PathUtils.addToJob(obj)
if not job:
raise ValueError(
"No job associated with the operation. Please ensure the operation is part of a job."
)
obj.Active = True
features = self.opFeatures(obj)

View File

@@ -33,7 +33,6 @@ import Path.Op.Base as PathOp
import Path.Op.Gui.Selection as PathSelection
import Path.Tool.Controller as PathToolController
from Path.Tool.library.ui.dock import ToolBitLibraryDock
import PathGui
import PathScripts.PathUtils as PathUtils
import importlib
from PySide.QtCore import QT_TRANSLATE_NOOP
@@ -422,9 +421,10 @@ class TaskPanelPage(object):
self.tcEditor.controller.hide()
def resetToolController(self, job, tc):
if self.obj is not None:
self.obj.ToolController = tc
self.setupToolController()
if self.obj is None:
return
self.obj.ToolController = tc
self.setupToolController()
def copyToolController(self):
oldTc = self.tcEditor.obj
@@ -1454,6 +1454,9 @@ def Create(res):
this function directly, but calls the Activated() function of the Command object
that is created in each operations Gui implementation."""
FreeCAD.ActiveDocument.openTransaction("Create %s" % res.name)
if res.job is None:
FreeCAD.ActiveDocument.abortTransaction()
raise ValueError("No job selected. Operation creation aborted.")
try:
obj = res.objFactory(res.name, obj=None, parentJob=res.job)
if obj.Proxy:
@@ -1502,6 +1505,17 @@ class CommandPathOp:
return False
def Activated(self):
jobs = PathUtils.GetJobs()
if not jobs:
return
job = PathUtils.UserInput.chooseJob(jobs)
if job is None:
return # Abort if no job selected or canceled
self.res.job = job
return Create(self.res)
def setJob(self, job):
self.res.job = job
return Create(self.res)

View File

@@ -26,7 +26,6 @@ import FreeCAD
import Path
import Path.Main.Gui.JobCmd as PathJobCmd
import Path.Tool.Controller as PathToolController
import PathGui
import PathScripts.PathUtils as PathUtils
from PySide import QtGui