docs: FreeCAD wiki updates for three macros (#18)

* docs: FreeCAD wiki updates for three macros

* Fix macro and wiki metadata

* fix: minor bugs in CutObjectForMagnets macro

1. Redundant distToShape call (lines 864-868)
Issue: The _get_inset_point method computed dist_info = cut_face.distToShape(Part.Vertex(inset_point)) at line 841, but then called distToShape again at line 867 with the same arguments.
Fix: Removed the redundant call and reused the already-computed dist_info result.

2. Redundant hide transaction in main() (lines 1907-1914)
Issue: main() had a "Transaction 7: Hide original object" that duplicated the hiding logic already in execute() Transaction 8 (lines 1391-1412). Additionally, the main() version had worse error handling (re-raised exceptions instead of gracefully continuing).
Fix: Removed the redundant transaction block from main(). The execute() method's Transaction 8 already handles hiding the original object properly with graceful error handling.
This commit is contained in:
Sean P. Kane
2026-01-05 21:18:05 -08:00
committed by GitHub
parent f58b32831c
commit 4344ff7536
13 changed files with 712 additions and 20 deletions
@@ -6,8 +6,6 @@ Copyright (c) 2025 Sean P. Kane (GitHub: spkane)
Cuts an object along a plane and adds connector holes for magnets with
surface collision detection.
Version: 1.0.0
Requirements:
- FreeCAD 0.19 or later
- An object selected in the 3D view
@@ -19,6 +17,22 @@ Usage:
4. Click "Execute Cut"
"""
# FreeCAD Addon Manager metadata
__Name__ = "Cut Object for Magnets"
__Comment__ = "Cut an object along a plane and add aligned magnet holes with surface collision detection"
__Author__ = "Sean P. Kane"
__Version__ = "0.5.0-beta"
__Date__ = "2026-01-05"
__License__ = "MIT"
__Web__ = "https://github.com/spkane/freecad-robust-mcp-and-more"
__Wiki__ = "https://github.com/spkane/freecad-robust-mcp-and-more#readme"
__Icon__ = ""
__Help__ = "Select an object to cut, run the macro, configure cut plane and magnet hole parameters, then click Execute Cut. Creates two parts with aligned magnet holes."
__Status__ = "Beta"
__Requires__ = "FreeCAD 0.19+"
__Communication__ = "https://github.com/spkane/freecad-robust-mcp-and-more/issues"
__Files__ = ""
import FreeCAD as App
import FreeCADGui as Gui
import Part
@@ -848,9 +862,9 @@ class SmartCutter:
closest_on_face = dist_info[1][0][0]
return App.Vector(closest_on_face)
else:
# Point is not on the face - for ring shapes, we may need
# to adjust. Try projecting directly onto the face.
dist_info = cut_face.distToShape(Part.Vertex(inset_point))
# Point is not on the face - for ring shapes, the inset point
# may land in the hole. Return the closest point on the face
# from the already-computed dist_info.
return App.Vector(dist_info[1][0][0])
except Exception as e:
App.Console.PrintWarning(f"Failed to validate inset point: {e}\n")
@@ -1888,16 +1902,7 @@ def main():
bottom_body, top_body = cutter.execute(progress_update)
# Bodies are already created in the document by execute()
# Just need to finalize and hide original
# Transaction 7: Hide original object
App.ActiveDocument.openTransaction("Hide Original Object")
try:
obj.ViewObject.Visibility = False
App.ActiveDocument.commitTransaction()
except Exception:
App.ActiveDocument.abortTransaction()
raise
# Original object is hidden in execute() Transaction 8
App.ActiveDocument.recompute()