FreeCAD Plugins


There are basically two ways to add functionality to FreeCAD.
1. Workbenches
2. Macros

Workbenches

Workbenches can be thought of the set of tools grouped together to perform a specific task. Workbenches can be C++ or Python modules. The C++ ones written earlier are bundled with FreeCAD itself like Part, PartDesign, Mesh. More information regarding this can be found at http://www.freecadweb.org/wiki/?title=Workbenches.

Workbenches that are being written in Python are managed at https://github.com/FreeCAD/FreeCAD-addons so that they can be separated out from FreeCAD and plugged in later on. Hence, it becomes easy to handle Python modules as they don’t need compilation. Python workbenches are Arch, openSCAD, ship etc.

Some are hybrid (combination of C++ and Python) like PathDraft etc.

Macros

Macros can be visualized as single-file python scripts. These are having .FCMacro file extension. There are two ways to record macros.

1. Interactive: Go to Menu > Macro > Macro recording > Enter any name > Click ‘Record‘ > Do whatever you want to do and then click Macro > Stop macro recording. Read more: http://www.freecadweb.org/wiki/index.php?title=Macros

2. Python: Go to MenuMacro >  Macros > Create > Enter file name > Click ‘OK‘ > Write python code and save (Ctrl+S).

Macros are located at the FreeCAD wiki: http://www.freecadweb.org/wiki/index.php?title=Macros_recipes. Later, it was thought to port those macros to GitHub: https://github.com/FreeCAD/FreeCAD-macros. As one doesn’t need to know programming to create Macros, hence a normal user finds it difficult to use git and GitHub and most macro authors don’t have a GitHub account so they didn’t move the macros there. And the wiki is very easy for people to put their macros.

 

Hence, the idea is to implement a plugin manager that would be managing both Workbenches and the Macros without giving much hassle to the users to install them, via a single interface.

Currently, the installation directory for ~/.FreeCAD/Mod (in GNU/Linux at least). To see the User Data directory, go to FreeCAD Python console and paste:

print FreeCAD.getUserAppDataDir()

This will print the directory where to store the plugins. Mod is for containing the workbenches and the Macro directory is for storing the user created macros.

Advertisements

Compiling FreeCAD on Ubuntu 16.04


Read my another post to compile FreeCAD on Arch: https://mandeep7.wordpress.com/2016/03/30/compiling-freecad-from-source-on-arch-linux/

Getting the source:

git clone https://github.com/FreeCAD/FreeCAD free-cad-code

Getting the dependencies:

sudo apt install build-essential cmake python python-matplotlib libtool libcoin80-dev libsoqt4-dev libxerces-c-dev libboost-dev libboost-filesystem-dev libboost-regex-dev libboost-program-options-dev libboost-signals-dev libboost-thread-dev libboost-python-dev libqt4-dev libqt4-opengl-dev qt4-dev-tools python-dev python-pyside pyside-tools oce-draw libeigen3-dev libqtwebkit-dev libshiboken-dev libpyside-dev libode-dev swig libzipios++-dev libfreetype6 libfreetype6-dev liboce-foundation-dev liboce-modeling-dev liboce-ocaf-dev liboce-visualization-dev liboce-ocaf-lite-dev libsimage-dev checkinstall python-pivy python-qt4 doxygen libspnav-dev

Compiling:

Now first we’ll create a separate directory for storing our build files. This will be out-of-source build. Which means the source code directory will not get modified and there won’t be any issue with git.

mkdir build

cd build

cmake

For example, if you have two directories: build and free-cad-code, then go to build directory and run:

cmake ../free-cad-code

Here free-cad-code is my source code directory.

While running cmake, I got an error:

make[2]: *** No rule to make target ‘/usr/lib/libfreeimage.so’, needed by ‘lib/libSMDS.so’. Stop.

This was solved by creating a symlink from /usr/lib/x86_64-linux-gnu/libfreeimage.so to /usr/lib/libfreeimage.so

sudo ln -s /usr/lib/x86_64-linux-gnu/libfreeimage.so /usr/lib/libfreeimage.so

If the above cmake process worked successfully then proceed to the following or just analyze the error and install the missing dependencies. Now type:

make

to start the compilation.

To speed up the compilation, I did: make -j4 instead of make. It will make the full utilization of CPU and memory. Here 4 is the number of cores. You may find yours using command: nproc or simply run make -j$(nproc)

But wait, I got into a problem due to that. The C++ compiler ran out of memory while compilation. It threw an error:

c++: internal compiler error: Killed (program cc1plus)

Please submit a full bug report, with preprocessed source if appropriate.

See <file:///usr/share/doc/gcc-5/README.Bugs> for instructions.

It was due to the full memory utilization and compiler ran out of memory. I got help regarding this by one of the mentors (ickby) on #freecad irc channel.

Then I tried with make -j2 and it worked flawlessly.

Execution:
Execute using the following command:
./bin/FreeCAD

Source: http://www.freecadweb.org/wiki/?title=CompileOnUnix

Compiling FreeCAD from source on Arch Linux


Getting the source:

git clone https://github.com/FreeCAD/FreeCAD free-cad-code

Getting the dependencies:

You will need the following libraries from the official repositories:

Just use:

sudo pacman -Syu  boost-libs curl hicolor-icon-theme libspnav opencascade python2-pivy python2-matplotlib python2-pyside python2-shiboken qtwebkit shared-mime-info xerces-c boost cmake coin desktop-file-utils eigen gcc-fortran swig xerces-c

And one with yaourt:

yaourt -S python2-pyside-tools

Compiling:

cd free-cad-code (the folder where you cloned the freecad source)

For a Release build:

$ cmake -DFREECAD_USE_EXTERNAL_PIVY=1 -DCMAKE_BUILD_TYPE=Release .
$ make -j4
Execution:
Execute using the following command:
./bin/FreeCAD

 

Source: http://www.freecadweb.org/wiki/?title=CompileOnUnix