Skip to content

About

Parametric wooden window frames FreeCAD workbench, scaled to model railroad scales for STL export

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Window Frames workbench for FreeCAD

Create parametric wooden window frames.

  • Rough opening - enter the width and height of the hole in the wall.
  • Panes - choose the number of rows and columns of glass.
  • Type - Fixed (cannot open) or Double Hung (two sashes that slide up and down). Double Hung windows have LowerSashOpen / UpperSashOpen sliders (0-100 %) so you can see the window partly open.

For a Double Hung window, rows and columns are counted per sash (2 columns x 3 rows gives a "6 over 6").

Export to model railroad scales (STL)

The window object always stays at real size. To make a model, select one or more windows (or select none to export every window in the document) and click Export STL.... Choose:

Option What it does
Scale Z 1:220, N 1:160, N (UK) 1:148, TT 1:120, HO 1:87.1, OO 1:76.2, S 1:64, O 1:48, O (UK) 1:43.5, Gauge 1 1:32, G 1:22.5, or any custom 1:x
Include glass Off by default: the panes print as openings, and the dialog tells you the size of the clear sheet to cut for each pane
Print orientation Upright, or lying flat with the exterior or interior face on the bed
Smallest printable detail Members thinner than this at model scale (default 0.3 mm) are thickened to it, and hairline sash gaps are closed so the sashes fuse to the frame. Set to Off for a strictly proportional model

The STL is in millimetres at model size, with its lower corner at the origin. It is a single closed solid (touching parts are merged), so slicers accept it without repair. Overall size is the frame (the rough opening less the clearance), so it drops into a wall opening scaled the same way. One file is written per window; with several windows you pick a folder.

The exporter's last settings are remembered. It can also be called from a macro:

from freecad.windowframes import export
export.export_window(App.ActiveDocument.Window, "/tmp/w.stl", 87.1)

Because the STL is produced from the window's parameters, it does not depend on the object's Placement, and a Double Hung window is exported with its sashes at the current LowerSashOpen / UpperSashOpen positions.

Install (manual)

  1. In FreeCAD's Python console run App.getUserAppDataDir(); it prints the user data directory (Linux: ~/.local/share/FreeCAD/, Windows: %APPDATA%\FreeCAD\, macOS: ~/Library/Application Support/FreeCAD/).
  2. Copy this whole WindowFrames folder into the Mod folder inside it.
  3. Restart FreeCAD and pick Window Frames from the workbench dropdown.

Use

Click New Window, fill in the dialog, press OK. Every dimension is a property of the object (Property editor, Window / Frame / Glazing / Sashes groups) and can be changed at any time or bound to a Spreadsheet with an expression. The calculated size of one pane of glass is shown under Results.

Local axes: X = width, Y = depth (0 = exterior face, +Y = interior), Z = height, with the origin at the bottom-left of the rough opening as seen from outside (FreeCAD's Front view). Use the object's Placement to move it into your wall.

Units: enter lengths as 900 mm, 36 in, 3 ft. A bare number is millimetres.

Tests

The geometry has no FreeCAD dependency:

python3 -m unittest discover -s tests -v

Layout

Init.py, InitGui.py      FreeCAD entry points
package.xml              Addon Manager metadata
freecad/windowframes/
    geometry.py          pure-Python box layout (unit tested)
    scaling.py           scale presets, thickening, print orientation (unit tested)
    stl_writer.py        merges boxes into one closed solid, writes binary STL (unit tested)
    export.py            finds windows / reads their parameters
    exportdialog.py      "Export STL" dialog
    window.py            parametric object + make_window()
    view_provider.py     icon and wood/glass colours
    taskpanel.py         "New Window" dialog
    commands.py          toolbar / menu command

Development

Clone the repo somewhere convenient (not inside FreeCAD's folders), then link it into FreeCAD so edits take effect on the next FreeCAD start. From a Command Prompt (no admin needed):

mklink /J "%APPDATA%\FreeCAD\Mod\WindowFrames" "C:\dev\WindowFrames"

(Use the folder that App.getUserAppDataDir() prints in FreeCAD's Python console.) Run the tests with python -m unittest discover -s tests -v, or from VS Code's Testing panel.

About

Parametric wooden window frames FreeCAD workbench, scaled to model railroad scales for STL export

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages