Hallo,
i'm new here and hope somebody can help.
I try to extract the names and the corresponding shapes from a
step.file. Because OCC dont offer a function i translated following
functions into python: http://opencascade.wikidot.com/entitynames
The result is posted at the end. The second function 'dumpLabels' is
working fine. But here i had to use StepRepr_RepresentationItem instead
of StepRepr_Representation. No idea why...
But the main problem is in the first function. 'binder.IsNull()' returns
all the time True. But i know that the step file is correct. I opened
and explored it in salome an got the shapes with there names.
One more minor point: Is there a better way for translating '->' with
GetObject(). Example: from C 'theSession->Model()' to python
'theSession.GetObject().Model()'
I would be glad to get a answer for this problem. Or maybe somebody
already translated these functions?
best regards
Paul
***************************************************************************************
reader = STEPControl_Reader()
reader.ReadFile('***.step')
***************************************************************************************
def getShape(shapeName):
ascShapeName=TCollection_AsciiString(shapeName)
theSession = reader.Reader().WS()
theModel = theSession.GetObject().Model()
aReader = theSession.GetObject().TransferReader()
tp = aReader.GetObject().TransientProcess()
nb = theModel.GetObject().NbEntities()
retShape = TopoDS_Shape()
for i in range(1,nb):
ent=
Handle_StepRepr_RepresentationItem_DownCast(theModel.GetObject().Value(i))
if (ent.IsNull()):
continue
binder = tp.GetObject().Find(ent)
if (binder.IsNull()):
continue
oneShape = TransferBRep().ShapeResult(binder)
if (oneShape.IsNull()):
continue
if (ent.Name().IsNull()):
continue
if(ent.GetObject().Name().GetObject().String().ToCString()==shapeName):
retShape=oneShape
print 'Erfolg'
return retShape
**********************************************************************************************
def dumpLabels():
theSession = reader.WS()
theModel = theSession.GetObject().Model()
nb = theModel.GetObject().NbEntities()
for i in range(1,nb)
ent=
Handle_StepRepr_RepresentationItem_DownCast(theModel.GetObject().Value(i))
if (ent.IsNull()):
continue
if (ent.GetObject().Name().IsNull()) or
(ent.GetObject().Name().GetObject().ToCString()==str()):
continue
print ent.GetObject().Name().GetObject().ToCString()
_______________________________________________
Pythonocc-users mailing list
Pythonocc-users@gna.org
https://mail.gna.org/listinfo/pythonocc-users