Dear pythonOCC users,
Here is a short development status after a couple of days of silence on
this ml.
- the OCAF missing modules (XCAFApp, XCAFDoc etc.) have been wrapped.
The complete OCC Application Framework should now be usable from python.
I attached a very basic sample to show how to use. A few more samples
are planned for the next days,
- I tried to include within pythonOCC a python wrapper for the Salomé
Geometry modules (see http://sourceforge.net/projects/salomegeometry).
This work is still very experimental and for Windows users only (didn't
manage to compile salomeGEOM on Linux platform). The Salomé GEOM API
offers a high-level topology/geometry layer combined with
parametric/associativity feature and could be of interest in pythonOCC.
The complete Salome GEOM API is 9 more modules. It's disabled by default
in the environment.py script (line 34: WRAP_SALOME_GEOM = False ).
- the __hash__() overload feature (also know as list/dict pythonOCC
feature), suggested by Frank Conradie, now works for both
Windows/Linux/MacOSX platforms.
This work is available on the SubVersion repository (svn rev.232). A
prebuilt binary was compiled for Windows-Python25 and can be downloaded
from the URL: http://www.pythonocc.org/Releases/daily/ .
Note that the current development status is close to the upcoming 0.2
release (except the scons script that is not up-to-date with recent
modifs) and should be considered as a "Release Candidate". Please report
any bug or weird behaviour.
Best Regards,
Thomas
#!/usr/bin/env python
##Copyright 2009 Thomas Paviot (thomas.pav...@free.fr)
##
##This file is part of pythonOCC.
##
##pythonOCC is free software: you can redistribute it and/or modify
##it under the terms of the GNU General Public License as published by
##the Free Software Foundation, either version 3 of the License, or
##(at your option) any later version.
##
##pythonOCC is distributed in the hope that it will be useful,
##but WITHOUT ANY WARRANTY; without even the implied warranty of
##MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
##GNU General Public License for more details.
##
##You should have received a copy of the GNU General Public License
##along with pythonOCC. If not, see <http://www.gnu.org/licenses/>.
from OCC.XCAFApp import *
from OCC.STEPCAFControl import *
from OCC.TDocStd import *
from OCC.TCollection import *
from OCC.XCAFDoc import *
from OCC.TDF import *
from OCC.TopoDS import *
#
# First open and parse STEP file
#
reader = STEPCAFControl_Reader()
print "1"
reader.ReadFile(str('test.stp'))
print "2"
#
# Create the TDocStd document
#
h_doc = Handle_TDocStd_Document()
print h_doc.IsNull()
#
# Create the application: really *awfull* way to do that
#
#app = Handle_XCAFApp_Application().GetObject()
app = GetApplication().GetObject()
app.NewDocument(TCollection_ExtendedString("MDTV-CAF"),h_doc)
print "3"
#
# Transfer
#
print h_doc.IsNull()
if not reader.Transfer(h_doc):
print "Error"
print "4 bis"
#
# Get root assembly
#
doc = h_doc.GetObject()
print "4"
h_shape_tool = XCAFDoc_DocumentTool().ShapeTool(doc.Main())
shape_tool = h_shape_tool.GetObject()
# get the top level shapes
l_LabelShapes = TDF_LabelSequence()
shape_tool.GetShapes(l_LabelShapes)
print "5"
l_Colors = XCAFDoc_DocumentTool().ColorTool(doc.Main())
#
shapes = []
for i in range(1,l_LabelShapes.Length()):
#print l_LabelShapes.Value(i)
shape = shape_tool.GetShape(l_LabelShapes.Value(i))
shapes.append(shape)
print shapes
if 'display' in dir():
display.EraseAll()
for shape in shapes:
display.DisplayShape(shape)
_______________________________________________
Pythonocc-users mailing list
Pythonocc-users@gna.org
https://mail.gna.org/listinfo/pythonocc-users