Merge pull request #25960 from Connor9220/FixBoundaryDressup

CAM: Refactor stock used as boundary to be distinct from regular stock
This commit is contained in:
sliptonic
2025-12-12 12:39:16 -06:00
committed by GitHub
2 changed files with 29 additions and 1 deletions

View File

@@ -46,6 +46,16 @@ def _vstr(v):
class DressupPathBoundary(object):
def promoteStockToBoundary(self, stock):
"""Ensure stock object has boundary properties set."""
if stock:
if not hasattr(stock, "IsBoundary"):
stock.addProperty("App::PropertyBool", "IsBoundary", "Base")
stock.IsBoundary = True
if hasattr(stock, "setEditorMode"):
stock.setEditorMode("IsBoundary", 3)
stock.Label = "Boundary"
def __init__(self, obj, base, job):
obj.addProperty(
"App::PropertyLink",
@@ -64,6 +74,7 @@ class DressupPathBoundary(object):
),
)
obj.Stock = PathStock.CreateFromBase(job)
self.promoteStockToBoundary(obj.Stock)
obj.addProperty(
"App::PropertyBool",
"Inside",
@@ -99,8 +110,14 @@ class DressupPathBoundary(object):
if prop == "Path" and obj.ViewObject:
obj.ViewObject.signalChangeIcon()
# If Stock is changed, ensure boundary stock properties are set
if prop == "Stock" and obj.Stock:
self.promoteStockToBoundary(obj.Stock)
def onDocumentRestored(self, obj):
self.obj = obj
# Ensure Stock property exists and is flagged as boundary stock
self.promoteStockToBoundary(obj.Stock)
if not hasattr(obj, "KeepToolDown"):
obj.addProperty(
"App::PropertyBool",
@@ -120,12 +137,20 @@ class DressupPathBoundary(object):
if obj.Base.ViewObject:
obj.Base.ViewObject.Visibility = True
obj.Base = None
if obj.Stock:
if hasattr(obj, "Stock") and obj.Stock:
obj.Document.removeObject(obj.Stock.Name)
obj.Stock = None
return True
def execute(self, obj):
if not hasattr(obj, "Stock") or obj.Stock is None:
Path.Log.error("BoundaryStock (Stock) missing; cannot execute dressup.")
obj.Path = Path.Path([])
return
if not hasattr(obj.Stock, "Shape") or obj.Stock.Shape is None:
Path.Log.error("Boundary stock has no Shape; cannot execute dressup.")
obj.Path = Path.Path([])
return
pb = PathBoundary(obj.Base, obj.Stock.Shape, obj.Inside, obj.KeepToolDown)
obj.Path = pb.execute()

View File

@@ -261,6 +261,9 @@ class ViewProvider:
def editObject(self, obj):
if obj:
# Block editing for Boundary objects
if hasattr(obj, "IsBoundary") and getattr(obj, "IsBoundary", False):
return False
if obj in self.obj.Model.Group:
return self.openTaskPanel("Model")
if obj == self.obj.Stock: