For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings


Need to speed up your development?
Have a look at our:

Samples & Tools


Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages


jelle's picture

Hi, I'm very impressed with some of the efforts binding openCASCADE to python. I'd be very interested to know what kind of efforts are being made right now in coupling openCASCADE right now, since for instance pythonCASCADE dates back 'til 2003, hence I'm curious about more current efforts. Cheers, Jelle

Marco Nawijn's picture

Hi Jelle,

I am also very interested in the python/opencascade bindings. I have written an e-mail to the Opencascade company
itself and they confirmed that they have a python binding, but they will not release it to the public :(.

I am willing to give it a try myself, but I am not an experienced C++ programmer and as you probably know, the
Opencascade library is huge. My main motivation would be to use the binding as a core component for a
Python based knowledge based engineering application similar to ICAD (bought by Dassault Systemes) and Genworks(

Maybe we can combine our efforts and start with a small demonstration program.



Andy's picture

Hi Marco,

I have written some Python bindings for OCC. The objects provide similar functionality to the ICAD geometry objects, although they are not as complete as the ICAD objects and functions at the moment.

SWIG is used to generate the bindings and wxPython is used for the display. Rather than trying to wrap all of the OCC objects, I have created simplified objects (similar to those you would use in ICAD) and wrapped these simplified objects. This seemed to be the most appropriate method since it gave me more control over the interface.

I'm planning on releasing the software at the end of the year. The solution focuses more on knowledge lifecycle and process capture than on KBE so the OCC bindings are just a small part of the overall functionality.


Marco Nawijn's picture

Hi Andy,

Thanks for your response. Interesting to see that you are working on KBE lifecycle and process capture with Python/OCC (and probably other software). I have a few questions:

1.) Can you tell me which OCC objects you have wrapped? I would like to build a demo application where all the bits and pieces
are functioning.

2.) Can you show me an example on how to render OCC output to a wxPython window. This will probably save me a lot of time!

I have worked with SWIG before. I once wrapped the SILO library (for building computational databases) and that worked
quite well for me. However, I don't know how well this works for a library as large as OCC. Currently, I am looking into
boost.python and py++. I will probably try to wrap a few classes with these tools and see how it works.

Thanks again,


Andy's picture

Hi Marco,

As I mentioned, I started by defining the objects that I would want to work with. For example:


I then defined these to have the attributes and methods that I would want to work with. In certain cases these may call on a number of different OCC objects. For instance, the Curve object returns a Normal at a specific U value and so uses the GeomLProp_CLProps object under the covers.

I then wrapped these simplified objects using SWIG, which was simply a matter of including my header files (with the occasional "#ifndef SWIG ...").

I have an object called Display. This obviously handles the display of all of the objects, including things such as zoom, pan, rotate, etc. Display also has a method “SaveAsBMP” which can be called interactively or programmatically to grab the screen.

I call the Display object from Python using something like this:

self.OCCDisplay = Display()
self.OCCDisplay.SetBackgroundColour(0.200, 0.200, 0.400)

Where "self" in this instance is based on a wx.Panel.

Once you’ve got the hWnd, the code to initialise the display is pretty standard I think. Something like:

Handle(Graphic3d_WNTGraphicDevice) graphicDevice= new Graphic3d_WNTGraphicDevice;
Handle(WNT_Window) aWNTWindow= new WNT_Window(graphicDevice, (HWND*)_hWnd);
Handle(V3d_Viewer) viewer = new V3d_Viewer(graphicDevice, (short* const)"viewer");
view = viewer->CreateView();
context = new AIS_InteractiveContext(viewer);

Hope that helps.


Andy's picture

Hi Marco,

I've thrown a few examples onto a web page so you can take a look if you like.

Apologies for the rough look, but hopefully you get the idea. All of the examples are written in Python using the wrapped objects.


Marco Nawijn's picture

Hi Andy,

Looks nice! At the moment I am setting up my new Macbook
for compiling Opencascade. This should not be a very big
problem. Further, I decided to try to wrap the FoundationClasses using boost.python and py++. I will keep you informed about the progress. If all things turnout fine, I will contribute the wrapper to the OCC community.

Thanks a lot for your response!


jelle's picture

Hi Andy & Marco,

What an interesting thread this has become!
I'm very excited to see both Andres screenshots & Marco intention of wrapping the FoundationClasses. I wonder what the overlap is between both your projects.

Andy, I've tried to reach you via email, but haven't been able to find your address.
Would you be so kind to drop me a line on ?