Home

Collaborative development portal

Search form

  • Sign in
  • Get involved
  • Resources
    • Download
    • Issue tracker
    • Git repository
    • Components
    • Online-documentation
    • Training & E-learning
    • Technical support
    • FAQ
    • Licensing
  • Blog
  • Forum
    • All Forums
    • Active Topics
  • About
  • Research & Science
  • Projects & Products
  • Contact us

pythonOCC

Thomas Paviot's picture
Thomas Paviot
Wed, 03/12/2008 - 12:09
Forums: 
pythonOCC
See More

Hello,

I've been working, for a couple of weeks, on a python wrapper for OpenCascade 6.2.0 library. The development is in a very early stage, but i decided to release my work under a free licence (CeCILL) and set up different tools to enable collaborative work on this project.

You can find info, mailing list, SVN anonymous access, prebuilt binaries for Windows on the project web page:

http://www.minerva-plm.org/pythonOCC/

You're welcome to help in any way(testing, bug report, patches, doc etc.). Only 20 out of 4000 objects are currently wrapped. Py++ code generator for Boost.Python library is used to achieve the work.

Regards,

Thomas Paviot
thomas_dot_paviot_at_supmeca_dot_fr

  • Log in to post comments
Darren's picture
Darren
Wed, 03/12/2008 - 14:51

Hi,
This sounds like a great project. I am a user of Blender 3d (which also uses python), and I can see these would be of great benefit for use with Blender.

You have said that currently only 20 objects are wrappped. What are these and can they provide cad or solid modelling fuctions to Blender - or should I wait until most of them are wrapped before they can be of benefit?

Best of luck with your work. It will be much apreciated.

  • Log in to post comments
Thomas Paviot's picture
Thomas Paviot
Wed, 03/12/2008 - 17:24

pythonOCC is intented to provide a rapid prototyping tool for OpenCascade apps development.

There are currently 3 types of wrapped objects:
- gp* : gp_Lin, gp_Pnt, etc. excepted gp_Mat and gp_Mat2d
- GCE2d* : GCE2d_MakeLine, etc.
- GC* : GC_MakeLine, GC_MakeCircle, etc.

PY++ is a very convenient tool to develop Python bindings for C++ libs and the number of available object should quickly grow. I plan to wrap the whole OCC library but it's very time consuming. That's why I expect help from OCC users, once the development framework will be completely uploaded to the SVN repository I set up.

  • Log in to post comments
Steve's picture
Steve
Fri, 03/14/2008 - 15:10

Hello,

why are you not using the wrapper classes form http://jcae.sourceforge.net/, which are compiled with swig for java. But you could compile it also for any other language like Python

  • Log in to post comments
Thomas Paviot's picture
Thomas Paviot
Mon, 03/17/2008 - 15:55

Hello,

That's what I did in a first step. Although I had a few problem while hacking *.i jcae files in order to create a Python wrapper, another issue lead me to Py++ : the high number of OpenCascade classes require an automated tool to generate all the .i Swig files. I did not find such a tool.

  • Log in to post comments
Dan Heeks's picture
Dan Heeks
Wed, 03/26/2008 - 18:35

Thomas,
This is just what I need for a python CAD/CAM project I am planning.
I have tried this link http://www.minerva-plm.org/pythonOCC/
The link for "2. pythonOCC 0.15 Windows Installer for Python 2.4." works OK,
but the link for "1. pythonOCC 0.15 Windows Installer for Python 2.5." does not work.
Does this exe exist?
Dan Heeks

  • Log in to post comments
Thomas Paviot's picture
Thomas Paviot
Thu, 03/27/2008 - 19:56

Dan,

The link was broken. I just uploaded a new release of pythonOCC that should work for both Python 2.4 and Python 2.5. Note that I work under Windows and I did not try the wrapper for Unix or Linux. It's in my "todo" list.

The number of wrapped object significantly grew and can be accessed from http://www.minerva-plm.org/pythonOCC/pythonOCC_APIREF.html .

Regards,

Thomas

  • Log in to post comments
Dan Heeks's picture
Dan Heeks
Fri, 03/28/2008 - 14:20

Thomas, thank you! It works now.

  • Log in to post comments
ogcnet's picture
ogcnet
Sun, 11/29/2015 - 19:15

while hacking *.i jcae files in order to create a Python wrapper, another issue lead me to Py++ : the high number of OpenCascade classes

I have tried this link http://www.minerva-plm.org/pythonOCC/

  • Log in to post comments
Dan Heeks's picture
Dan Heeks
Fri, 03/28/2008 - 15:59

How do I use GC_MakeLine?

I tried the example:

P1 = gp.gp_Pnt2d(1,2)
P2 = gp.gp_Pnt2d(3,-5.1)
makeline = GCE2d.GCE2d_MakeLine(P1,P2)
makeline.IsDone()
makeline.Status()

and I got this error:

makeline.Status()
TypeError: No to_python (by-value) converter found for C++ type: enum gce_ErrorType

  • Log in to post comments
Thomas Paviot's picture
Thomas Paviot
Fri, 03/28/2008 - 17:18

I forgot to include gce_ErrorType enum in gce module. I fixed it and should be correct in the next release.

  • Log in to post comments
Thomas Paviot's picture
Thomas Paviot
Fri, 04/04/2008 - 13:42

Dan,

I uploadad a new release that fixes that bug and adds new wrappers for following modeling modules : gce, Geom, Convert and Geom2d.

Available at : http://www.minerva-plm.org/pythonOCC

Thomas

  • Log in to post comments
Dan Heeks's picture
Dan Heeks
Fri, 04/04/2008 - 18:02

Yes, this fixes the problem. Thanks!
All this code now works:
P1 = gp.gp_Pnt2d(1,2)
P2 = gp.gp_Pnt2d(3,-5.1)
makeline = GCE2d.GCE2d_MakeLine(P1,P2)
makeline.IsDone()
makeline.Status()

shape = BRep.BRepPrimAPI_MakeSphere(20);
shape2 = BRep.BRepPrimAPI_MakeSphere(gp.gp_Pnt(10,0, 0),22);
ShapeCut = BRep.BRepAlgoAPI_Cut(shape, shape2);

Can I use this function yet? ( I want to use triangulation )
BRep.BRepMesh_Mesh(ShapeCut, 0.1);

  • Log in to post comments
Thomas Paviot's picture
Thomas Paviot
Sat, 04/05/2008 - 18:03

The Mesh algorithms have not yet been wrapped.

BTW, I updated the APIREF page with a more readable one built upon pydoc.

See http://www.minerva-plm.org/pythonOCC/APIREF/OCC.html

  • Log in to post comments
Thomas Paviot's picture
Thomas Paviot
Tue, 04/08/2008 - 12:57

I just released a new version of pythonOCC. Basic BRep mesh algorithms are implemented and a lot of member functions have been added for each class (new inheritance mechanism). IGES export is possible.

URL : http://www.minerva-plm.org/pythonOCC

New API Reference : http://www.minerva-plm.org/pythonOCC/APIREF/OCC.html

  • Log in to post comments
Dan Heeks's picture
Dan Heeks
Tue, 04/08/2008 - 21:40

Good. This allows BRep.BRepMesh.Mesh to work. This is getting exciting now.
shape = BRep.BRepPrimAPI_MakeSphere(20)
shape2 = BRep.BRepPrimAPI_MakeSphere(gp.gp_Pnt(10,0, 0),22)
ShapeCut = BRep.BRepAlgoAPI_Cut(shape, shape2)
cut_shape = ShapeCut.Shape()
mesh = BRep.BRepMesh.Mesh(cut_shape, 0.1)

Next, I want to transfer this C code to Python ( to render all the triangles with OpenGL )
TopExp_Explorer ex;
for ( ex.Init( m_shape, TopAbs_FACE ) ; ex.More(); ex.Next() )
{
TopoDS_Face F = TopoDS::Face(ex.Current());
TopLoc_Location L;
Handle_Poly_Triangulation facing = BRep_Tool::Triangulation(F,L);
const Poly_Array1OfTriangle &triangles = facing->Triangles();
const TColgp_Array1OfPnt & nodes = facing->Nodes();
if (!facing.IsNull())
{
for ( int i=facing->NbTriangles(); i >= 1; --i ) // (indeksy 1...N)
{
Poly_Triangle triangle = triangles(i);
Standard_Integer node1,node2,node3;
triangle.Get(node1, node2, node3);

so, I am stuck trying to find TopExp_Explorer

  • Log in to post comments
Thomas Paviot's picture
Thomas Paviot
Fri, 04/11/2008 - 12:59

The new release of pythonOCC adds TopExp module as well as IGES import fixes and STL import/export.

Enjoy.

  • Log in to post comments
Dan Heeks's picture
Dan Heeks
Sat, 04/12/2008 - 22:17

Thanks.
This works OK now:
mesh = BRep.BRepMesh.Mesh(cut_shape, 0.1)
ex = TopExp.TopExp_Explorer()
ex.Init(cut_shape, TopAbs.TopAbs_FACE)
while ex.More():
F = TopoDS.TopoDS.Face(ex.Current())
# Get triangulation
L = TopLoc.TopLoc_Location()

I am now stuck trying to convert this C code
Handle_Poly_Triangulation facing = BRep_Tool::Triangulation(F,L);

  • Log in to post comments

© 2011-2022 OPEN CASCADE SAS
Terms of Use Privacy Policy
Cookie Policy Cookie settings
Open cascade in Facebook
Contact us