Skip to content

Freecad addon panel with some useful measuring and batch search/replace/export tools.

License

Notifications You must be signed in to change notification settings

AlansCodeLog/freecad-useful-panel

Repository files navigation

FreeCAD addon that does several useful things (am too lazy to create seperate addons):

  • Displays the current selection length.
  • Displays the distances between any two selections (similar to Part Measure Linear).
    • Plus additional X/Y/Z Min/Max measurements (i.e. the difference between the bounding edges of the selection). Sometimes the distance between two selections can be zero, but different size (e.g. two circles on top of each other, but their diameters are different). The min/max distances show this.
    • Now also supports showing the diameter when selecting circular edges.
measurements.mp4
  • Provides a way to find and replace text in expressions. Either in all documents, or only the current. Can also optionally replace text in spreadsheets.
    • Incredibly useful if you have a lot of variables and like to rename things.
    • Has a preview of the replace text, and matches can be omitted via a checkbox.
    • CAREFUL: This is a simple text replacement, and the outputted expression is not guaranteed to be valid.
    • This can also be used to find objects that use a variable. Clicking on the row will bring it into focus if Focus Object on Selection is enabled.

  • Provides a way to export all "marked" objects. Marking is done by including the word "Export" in the part's Label2 property.
    • Path are relative to each file by default but can be made relative to just the active file. Parts are named {file name}-{object name}-{optional suffix}.{extension}.
      • Optional suffix can be set by doing Export(your suffix here), this can be a version number or some other information. You can even use expressions to set the value. Note you will have to click the expression icon, the = shortcut doesn't work here.
    • You can check the report view to see where objects were saved.
    • The file is always overwritten if it exists.

Installation

This is not currently published to the freecad plugin manager. You will need to git clone it into your freecad config folder, inside the Mod folder. See Manual Install of Addons

You can do freecad --get-config UserAppData in the command line or FreeCAD.ConfigGet("UserAppData") in freecad` to check where this is.

git clone https://github.com/AlansCodeLog/freecad-useful-panel.git

Notes

  • I suggest disabling loading partial documents if using replace in all documents. (General => Document => Document objects => Disable partial loading of external linked objects). I've not tested this with partially loaded docs and I've had problems with them with other addons so don't use partial loading.

Todos

  • At some point I would like to see if it's possible to move the measurements to the viewport a la Fusion360.

Development

git clone https://github.com/alanscodelog/freecad-useful-panel.git #into freecad Mod folder
python3 -m venv .venv
pip install -r requirements.txt # for types and basic linting
git clone https://github.com/CyrilWaechter/freecad-stubs.git

For intellisence in vscode create .env with:

FREECAD_LIB=/usr/lib/freecad/lib
FREECAD_MOD=/path/to/Mod #replace
FREECAD_STUBS=./freecad-stubs/out
FREECAD_EXT=/usr/lib/freecad/Ext
SELF=./ # this is needed for freecad.* imports to work
PYTHONPATH=${FREECAD_STUBS}:${FREECAD_MOD}:${FREECAD_LIB}:${FREECAD_EXT}:${PYTHONPATH}:${SELF}

FREECAD_STUBS is the out folder generated by freecad-stubs

Now intellisence should work (autocomplete on App should work, etc.)

There's a few issues with PySide overloaded functions and some things are missing, but mostly works now.

Module layout is based on FreeCAD/freecad.workbench_starterkit

Bumping Version

Version needs to be bumped in freecad/useful_panel/version.py and package.xml.

About

Freecad addon panel with some useful measuring and batch search/replace/export tools.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages