OpenCamLib
Description
OpenCamLib (OCL) is an open source library aiming to provide computer aided manufacturing (CAM) algorithms. FreeCAD uses OCL for the 3D Surface and
Waterline Operations, the experimental
Rotary Surface Operation, and as the gate for the
CAMotics simulator integration. These commands are hidden until Enable OCL dependent features is checked on the page and FreeCAD is restarted.
Github: github.com/aewallin/opencamlib
Website: www.anderswallin.net/CAM/
Installing
Windows
Note: Recent Windows and macOS builds of FreeCAD ship OpenCamLib. If it is missing, install the opencamlib package into FreeCAD’s bundled Python (for example with the Addon Manager’s Python dependency installer or pip install opencamlib) so that import opencamlib succeeds. The historical ocl.pyd instructions below apply only to legacy builds.
To install OCL on Windows manually, follow these instructions.
-
Obtain the Python version of OpenCamLib (OCL).
-
Build from source using the Python version used by your FreeCAD version. Peter Lama’s fork of the same source has project files for a MSVC build.
-
Download the Python 2.7 x86/x64 binary by sgrogan on GitHub.
-
Download the Python 3.6 x64 binary by sgrogan on GitHub.
-
-
Navigate to your OCL build or binary folder
-
Copy the ocl.pyd library file
-
Proceed with one of the following four(4) options:
-
Navigate to your FreeCAD\lib folder, and paste the ocl.pyd file there. (''This is the preferred option.'')
-
Navigate to your FreeCAD\bin folder, and paste the ocl.pyd file there.
-
Navigate to your FreeCAD\Mod folder. Create a new folder, OCL. Enter the OCL folder and paste the ocl.pyd file.
-
Navigate to your %USERPROFILE%\AppData\Roaming\FreeCAD folder. Create a new folder, Mod. Enter the Mod folder. Create a new OCL folder. Enter the OCL folder and paste the ocl.pyd file. (''This is the least preferred option.'')
-
-
Restart FreeCAD
-
Verify proper installation
-
Click View → Panels → Python console.
-
Type "import ocl" into the Python console and press the enter key.
-
If no error appears, you have correctly installed OCL
-
If you receive an error:
-
Check the placement and name of the ocl.pyd file as instructed above
-
Verify the correct architecture type of the OCL library you installed - x86 or x64
-
Verify the Python version used to build the OCL library is the same as that of your FreeCAD software - 2.7 or 3.6 currently
-
-
-
Linux
The repository is here and contains basic installation instructions.
Before beginning installation, or during the installation process, you will probably find you need to install some additional packages:
Ubuntu/Debian
For example:
sudo apt install cmake
sudo apt install libboost-program-options-dev
# Optional, for documentation:
sudo apt-get install doxygen
sudo apt-get install texlive-full
Note: the "libboost-program-options-dev" may be substituted with "libboost-all-dev".
If you are struggling, carefully review any error messages you get during the cmake and make phases as you may need to install additional packages.
Archlinux
-
Install OpenCamLib from the AUR package.
-
If the package installs outside Python’s site-packages, run the following code snippet inside FreeCAD’s Python console before enabling the preference:
import sys
sys.path.append('/usr/opencamlib/')
import ocl
If the package installs into site-packages this is unnecessary; FreeCAD accepts either import ocl or import opencamlib.
Mac
git clone https://github.com/aewallin/opencamlib
cd opencamlib
mkdir build
cd build
cmake -DBUILD_PY_LIB=ON -DUSE_PY_3=ON -DCMAKE_BUILD_TYPE=Release .. -Wno-dev
make -j4
make install
To test the build enter the following in the Python console (either module name works):
import ocl # or: import opencamlib as ocl
dir(ocl)
The returned list should contain Waterline, AdaptiveWaterline and PathDropCutter, similar to:
['AdaptivePathDropCutter', 'AdaptivePathDropCutter_base', 'AdaptiveWaterline', 'AdaptiveWaterline_base', 'Arc', 'ArcSpanType', 'BallConeCutter', 'BallCutter', 'BatchDropCutter', 'BatchDropCutter_base', 'BatchPushCutter', 'BatchPushCutter_base', 'Bbox', 'BullConeCutter', 'BullCutter', 'CCPoint', 'CCType', 'CLPoint', 'CompBallCutter', 'CompCylCutter', 'ConeConeCutter', 'ConeCutter', 'CutterLocationSurface', 'CylConeCutter', 'CylCutter', 'Ellipse', 'EllipsePosition', 'Fiber', 'Fiber_base', 'Interval', 'Line', 'LineCLFilter', 'LineCLFilter_base', 'LineSpanType', 'MillingCutter', 'Path', 'PathDropCutter', 'PathDropCutter_base', 'Path_base', 'Point', 'STLReader', 'STLSurf', 'STLSurf_base', 'SpanType', 'Triangle', 'Triangle_base', 'Waterline', 'Waterline_base', 'WeaveVertexType', 'ZigZag', 'ZigZag_base', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'eps', 'epsD', 'epsF', 'version']
In case of an error the return value will be:
['__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__']
For cmake the Release option is very important, when using Debug area and ocl will collide and either library will not load (depending on what what was loaded first).
Enabling in FreeCAD
After installation, open , check Enable OCL dependent features and restart FreeCAD. FreeCAD imports the module as ocl or, failing that, opencamlib. If neither import works the report view prints "OpenCamLib is not working!" unless Suppress openCAMlib warning is checked.
Acknowledgments
Thank you to Dr. Anders Wallin for providing OCL to the public.