CAM: Do not show models of the toolbits in Job dialog (#22893)

This commit is contained in:
tarman3
2025-08-23 20:10:38 +03:00
committed by GitHub
parent d5361929f6
commit 9bcbc17433
3 changed files with 33 additions and 7 deletions

View File

@@ -77,10 +77,10 @@ def getPropertyValueString(obj, prop):
def setProperty(obj, prop, value):
"""setProperty(obj, prop, value) ... set the property value of obj's property defined by its canonical name."""
o, attr, name = _getProperty(obj, prop)
if not attr is None and type(value) == str:
if type(attr) == int:
if attr is not None and isinstance(value, str):
if isinstance(attr, int):
value = int(value, 0)
elif type(attr) == bool:
elif isinstance(attr, bool):
value = value.lower() in ["true", "1", "yes", "ok"]
if o and name:
setattr(o, name, value)
@@ -99,6 +99,10 @@ def isValidBaseObject(obj):
if hasattr(obj, "BitBody") and hasattr(obj, "ShapeName"):
# ToolBit's are not valid base objects
return False
if hasattr(obj, "ToolBitID"):
return False
if any(hasattr(ob, "ToolBitID") for ob in getattr(obj, "InListRecursive", [])):
return False
if obj.TypeId in NotValidBaseTypeIds:
Path.Log.debug("%s is blacklisted (%s)" % (obj.Label, obj.TypeId))
return False

View File

@@ -677,6 +677,26 @@ class StockFromExistingEdit(StockEdit):
if job.Stock in solids:
# regardless, what stock is/was, it's not a valid choice
solids.remove(job.Stock)
excludeIndexes = []
for index, model in enumerate(solids):
if [ob.Name for ob in model.InListRecursive if "Tools" in ob.Name]:
excludeIndexes.append(index)
elif hasattr(model, "PathResource"):
excludeIndexes.append(index)
elif model.InList and hasattr(model.InList[0], "ToolBitID"):
excludeIndexes.append(index)
elif hasattr(model, "ToolBitID"):
excludeIndexes.append(index)
elif model.TypeId == "App::DocumentObjectGroup":
excludeIndexes.append(index)
elif hasattr(model, "StockType"):
excludeIndexes.append(index)
elif not model.ViewObject.ShowInTree:
excludeIndexes.append(index)
for i in sorted(excludeIndexes, reverse=True):
del solids[i]
return sorted(solids, key=lambda c: c.Label)
def setFields(self, obj):
@@ -692,9 +712,9 @@ class StockFromExistingEdit(StockEdit):
for i, solid in enumerate(self.candidates(obj)):
self.form.stockExisting.addItem(solid.Label, solid)
label = "{}-{}".format(self.StockLabelPrefix, solid.Label)
if label == stockName:
index = i
self.form.stockExisting.setCurrentIndex(index if index != -1 else 0)
if not self.IsStock(obj):
@@ -1415,7 +1435,7 @@ class TaskPanel:
def isValidDatumSelection(self, sel):
if sel.ShapeType in ["Vertex", "Edge", "Face"]:
if hasattr(sel, "Curve") and type(sel.Curve) not in [Part.Circle]:
if hasattr(sel, "Curve") and not isinstance(sel.Curve, Part.Circle):
return False
return True
@@ -1424,7 +1444,7 @@ class TaskPanel:
def isValidAxisSelection(self, sel):
if sel.ShapeType in ["Vertex", "Edge", "Face"]:
if hasattr(sel, "Curve") and type(sel.Curve) in [Part.Circle]:
if hasattr(sel, "Curve") and isinstance(sel.Curve, Part.Circle):
return False
if hasattr(sel, "Surface") and sel.Surface.curvature(0, 0, "Max") != 0:
return False

View File

@@ -152,9 +152,11 @@ class JobCreate:
for base in self.candidates:
if (
not base in jobResources
base not in jobResources
and not PathJob.isResourceClone(job, base, None)
and not hasattr(base, "StockType")
and base.ViewObject.ShowInTree
and base.TypeId != "App::DocumentObjectGroup"
):
item0 = QtGui.QStandardItem()
item1 = QtGui.QStandardItem()