diff --git a/src/Mod/CAM/Path/Base/Util.py b/src/Mod/CAM/Path/Base/Util.py index e8bcbde5f9..33beb423e1 100644 --- a/src/Mod/CAM/Path/Base/Util.py +++ b/src/Mod/CAM/Path/Base/Util.py @@ -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 diff --git a/src/Mod/CAM/Path/Main/Gui/Job.py b/src/Mod/CAM/Path/Main/Gui/Job.py index ea33864664..cc76aac621 100644 --- a/src/Mod/CAM/Path/Main/Gui/Job.py +++ b/src/Mod/CAM/Path/Main/Gui/Job.py @@ -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 diff --git a/src/Mod/CAM/Path/Main/Gui/JobDlg.py b/src/Mod/CAM/Path/Main/Gui/JobDlg.py index 439f934b0f..a53c96a107 100644 --- a/src/Mod/CAM/Path/Main/Gui/JobDlg.py +++ b/src/Mod/CAM/Path/Main/Gui/JobDlg.py @@ -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()