From 6387014cd84bc1ebfafcf88ddcef5430dc4aa6cc Mon Sep 17 00:00:00 2001 From: Leandro Heck Date: Thu, 27 Jun 2024 11:00:56 -0300 Subject: [PATCH 1/2] Add the object name as the basename of unfolded objects --- SheetMetalUnfolder.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/SheetMetalUnfolder.py b/SheetMetalUnfolder.py index 5bd37e4..0756580 100644 --- a/SheetMetalUnfolder.py +++ b/SheetMetalUnfolder.py @@ -3142,7 +3142,12 @@ def processUnfold( if shape is None: raise UnfoldException() - unfoldShape = FreeCAD.ActiveDocument.addObject("Part::Feature", "Unfold") + try: + unfold_basename = object.Parents[0][0].Label + "_Unfolded" + except: + unfold_basename = "Unfolded" + + unfoldShape = FreeCAD.ActiveDocument.addObject("Part::Feature", unfold_basename) unfoldShape.Shape = shape if genSketch: @@ -3163,7 +3168,7 @@ def processUnfold( if not splitSketches: edges.append(foldEdges) - unfold_sketch = generateSketch(edges, "Unfold_Sketch", sketchColor) + unfold_sketch = generateSketch(edges, unfold_basename + "_Sketch", sketchColor) FreeCAD.ActiveDocument.recompute() if splitSketches: @@ -3189,7 +3194,7 @@ def processUnfold( FreeCAD.ActiveDocument.recompute() unfold_sketch_outline = generateSketch( - owEdgs, "Unfold_Sketch_Outline", sketchColor + owEdgs, unfold_basename + "_Sketch_Outline", sketchColor ) if tidy: @@ -3209,7 +3214,7 @@ def processUnfold( intEdgs.append(e) if len(intEdgs) > 0: unfold_sketch_internal = generateSketch( - intEdgs, "Unfold_Sketch_Internal", internalSketchColor + intEdgs, unfold_basename + "_Sketch_Internal", internalSketchColor ) except Exception as e: @@ -3224,7 +3229,7 @@ def processUnfold( if len(foldLines) > 0 and splitSketches: unfold_sketch_bend = generateSketch( - foldEdges, "Unfold_Sketch_bends", bendSketchColor + foldEdges, unfold_basename + "_Sketch_bends", bendSketchColor ) if FreeCAD.GuiUp: From 4fa38eacad7fb0e63eec5d350eff724fe79765b1 Mon Sep 17 00:00:00 2001 From: Leandro Heck Date: Thu, 27 Jun 2024 11:01:49 -0300 Subject: [PATCH 2/2] Match code style --- SheetMetalUnfolder.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/SheetMetalUnfolder.py b/SheetMetalUnfolder.py index 0756580..4a0b5c5 100644 --- a/SheetMetalUnfolder.py +++ b/SheetMetalUnfolder.py @@ -3143,11 +3143,11 @@ def processUnfold( raise UnfoldException() try: - unfold_basename = object.Parents[0][0].Label + "_Unfolded" + unfoldBaseName = object.Parents[0][0].Label + "_Unfolded" except: - unfold_basename = "Unfolded" + unfoldBaseName = "Unfolded" - unfoldShape = FreeCAD.ActiveDocument.addObject("Part::Feature", unfold_basename) + unfoldShape = FreeCAD.ActiveDocument.addObject("Part::Feature", unfoldBaseName) unfoldShape.Shape = shape if genSketch: @@ -3168,7 +3168,7 @@ def processUnfold( if not splitSketches: edges.append(foldEdges) - unfold_sketch = generateSketch(edges, unfold_basename + "_Sketch", sketchColor) + unfold_sketch = generateSketch(edges, unfoldBaseName + "_Sketch", sketchColor) FreeCAD.ActiveDocument.recompute() if splitSketches: @@ -3194,7 +3194,7 @@ def processUnfold( FreeCAD.ActiveDocument.recompute() unfold_sketch_outline = generateSketch( - owEdgs, unfold_basename + "_Sketch_Outline", sketchColor + owEdgs, unfoldBaseName + "_Sketch_Outline", sketchColor ) if tidy: @@ -3214,7 +3214,7 @@ def processUnfold( intEdgs.append(e) if len(intEdgs) > 0: unfold_sketch_internal = generateSketch( - intEdgs, unfold_basename + "_Sketch_Internal", internalSketchColor + intEdgs, unfoldBaseName + "_Sketch_Internal", internalSketchColor ) except Exception as e: @@ -3229,7 +3229,7 @@ def processUnfold( if len(foldLines) > 0 and splitSketches: unfold_sketch_bend = generateSketch( - foldEdges, unfold_basename + "_Sketch_bends", bendSketchColor + foldEdges, unfoldBaseName + "_Sketch_bends", bendSketchColor ) if FreeCAD.GuiUp: