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.
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(www.genworks.com).
Maybe we can combine our efforts and start with a small demonstration program.
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.
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
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.
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:
Apologies for the rough look, but hopefully you get the idea. All of the examples are written in Python using the wrapped objects.
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!
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 firstname.lastname@example.org ?