To start FreeCAD in console mode (this will drop you in to a python shell)
Linux/MacOS
Code: Select all
freecadcmd
or
freecad -c
Code: Select all
freecadcmd.exe
or
freecad.exe -c
The AppImage may not find certain modules, so it's possible to use the -M <path-to-system-python-modules> flag which directs it to use the system modules.
Code: Select all
# swap out for the correct path on your system
./FreeCAD.AppImage -c -M /usr/lib/python3.7/site-packages
Unpacked Appimage (link)
Code: Select all
FreeCAD.AppImage --appimage-extract
cd squashfs-root/
# swap out for the correct path on your system
./AppRun -c -M /usr/lib/python3.7/site-packages
What version of python is the shell running?
Code: Select all
import sys
print(sys.version)
Code: Select all
import readline
Code: Select all
import FreeCAD
Code: Select all
import readline, FreeCAD
Code: Select all
print(FreeCAD.Version())
Code: Select all
import pprint
pprint.pprint(FreeCAD.Version())
Code: Select all
FreeCAD.getUserAppDataDir()
Code: Select all
appdata = FreeCAD.getUserAppDataDir()
print(appdata)
Code: Select all
dir(FreeCAD)
Code: Select all
pprint.pprint(dir(FreeCAD))
Code: Select all
help(FreeCAD.ConfigDump)
Code: Select all
print(FreeCAD.ConfigDump())
# aaaand lets use pprint again
pprint.pprint(FreeCAD.ConfigDump())
Code: Select all
pprint.pprint(dir(FreeCAD.ConfigDump))
Code: Select all
import fancycompleter
fancycompleter.interact(persist_history=True)
Code: Select all
FreeCAD.<TAB>
We can import pretty much any workbench (Note: not all of them or their total functionalities are exposed to python)
Code: Select all
import Arch
import Draft
import Fem
import Part
import PartDesign
import Path
import Sketcher
import Spreadsheet
import TechDraw
Code: Select all
help(FreeCAD)
- Print the contents of user.cfg (openBrain's script)
- How to print the About FreeCAD version info to console? <-- anyone know how to do this?
- How to print all the python api functions for each workbench? help(FreeCAD)
- How to import external workbenches and some examples
- more...