Skip to content

Latest commit

 

History

History
65 lines (46 loc) · 3.9 KB

File metadata and controls

65 lines (46 loc) · 3.9 KB

FreeCAD Unified Workbench

Project Overview

This is a fork of FreeCAD that adds a unified workbench combining Sketch, Part Modeling (Features), and Assembly tools in one place — eliminating the need to switch between Sketcher, PartDesign, and Assembly workbenches during normal modeling workflows.

Goal: One workbench for the full modeling workflow (sketch → extrude → sketch on face → cut → assemble), plus quality-of-life enhancements.

Not a goal: Pixel-perfect SolidWorks UI replication. We borrow good ideas (unified toolbar, click-to-sketch-on-plane) but don't chase cosmetic similarity.

Key Directories

  • Mod/SolidWorksUI/ — Unified workbench + sketch enhancements
    • InitGui.py — Workbench registration, global feature install, Auto Constrain command
    • sw_constraint_observer.py — Document observer for redundant constraint handling + auto-external trigger
    • sw_auto_external.py — Auto-project face edges as external geometry
    • sw_sketch_commands.py — Sketch command wrappers (currently unused, kept for reference)
    • sw_feature_commands.py — Feature command wrappers (currently unused, kept for reference)
    • sw_utils.py — Shared helpers
    • tests/ — Unit tests (27 tests, run via pixi run freecadcmd tests/run_tests.py)
  • .devcontainer/ — Development container configuration
  • .claude-workspace/ — Persistent local workspace (gitignored, survives rebuilds)

Current State

The workbench is currently a minimal stub. Three features install globally at FreeCAD startup:

  1. Constraint redundancy observer — detects partially redundant constraints, shows popup dialog (or auto-removes based on preference)
  2. Auto-external geometry — projects solid face edges when sketching on a face
  3. Auto Constrain command (sketcher_auto_constrain) — re-applies missing constraints after trimming

Known issue: When a sketch enters edit mode, FreeCAD forces a switch to the Sketcher workbench (via ViewProviderSketch.EditingWorkbench property). This needs to be solved for the unified workbench to work.

Development Workflow

  1. VNC Desktop: Access at port 6080 (password: freecad)
  2. Run FreeCAD: cd .freecad-env && pixi run freecad
  3. Run headless: cd .freecad-env && pixi run freecadcmd -c "import FreeCAD; ..."
  4. Run tests: pixi run freecadcmd Mod/SolidWorksUI/tests/run_tests.py
  5. Workbench source: Edit files in Mod/SolidWorksUI/, restart FreeCAD to reload

FreeCAD Architecture Notes

  • App/Gui separation — App layer is GUI-independent. We only modify the Gui layer.
  • Workbench system — Each workbench registers commands, toolbars, menus. Only one is active at a time. Switching workbenches replaces all toolbars/menus.
  • Edit mode switchingViewProviderSketch::setEdit() reads the EditingWorkbench property and activates that workbench. Default is "SketcherWorkbench". Setting to "" prevents the switch, but Prop_ReadOnly may block Python writes.
  • Qt/PySide6 — GUI framework. Custom widgets use PySide6.
  • Command system — Commands registered globally via FreeCADGui.addCommand(). Available across workbenches if registered at import time.
  • Document observersFreeCAD.addDocumentObserver() registers callbacks for object creation/change/deletion. App-level, survives workbench switches.

Git

  • Remote: github.com:abwagner/FreeCAD
  • Push: GIT_SSH_COMMAND="ssh -i /workspaces/FreeCAD/.claude-workspace/github_ed25519 -o StrictHostKeyChecking=no" git push git@github.com:abwagner/FreeCAD.git main
  • Identity: git config user.name "claude" && git config user.email "abaranwagner+claude@gmail.com"

Testing

# Run all 27 unit tests
pixi run freecadcmd Mod/SolidWorksUI/tests/run_tests.py

# Verify imports
pixi run freecadcmd -c "import sys; sys.path.insert(0, 'Mod/SolidWorksUI'); import sw_constraint_observer; import sw_auto_external; print('OK')"