Archived discussion

How to get parameters from the Geom_Curve(s) ?

pythonOCCTue, 06/13/2017 - 21:495 replies

Browse this forum
QuestionAuthor

Hi, All

 

I've asked question few days ago wrt getting and extracting features from the STEp file using OCC/Python.

See https://www.opencascade.com/content/extract-shape-parameters-topodssolid... details, STEP file itself and solution proposed by Guido.

I pretty much converted his code to Python-OCC (plus aocutils), and was able to get a hierarchy of Shapes, Surfaces, Wires etc, please find test file attached.

But! How to upcast from Geom_Curve to Geom_Circle in Python-OCC? They are not members of the same hierarchy as C++ classes are. In general, how extract radii

from circle or points from spline?

 

Thank you,

SP

 

Discussion

5 archived replies

Posts are displayed in their archived order.

01Commenter-1

Hi Author,

I don't know how to cast the surface type in python, but I saw a small type error in your code:

edges0 = aocutils.topology.Topo(wire0, return_iter=False).edges

edges1 = aocutils.topology.Topo(wire0, return_iter=False).edges //should be wire1!

Best regards, Commenter-1

02Author

Hi, Guido

thank you.

yes, it was fixed shortly yesterday after I posted the message

Unfortunately, being unable to cast, the only good way to extract radius was to run circle.D0() method with

parameter (angle in this case) changing from 0 to \pi to \2pi. It worked but it is ugly

regards

SP

03Commenter-1

Hi Author,

In a example of occ python i saw a cast like this:

surf = Handle_Geom_Plane_DownCast(BRep_Tool_Surface(face)).GetObject()

from OCC.Geom import Handle_Geom_BSplineCurve_DownCast

SPL3 = Handle_Geom_BSplineCurve_DownCast(SPL1_c.Translated(gp_Vec(10, 0, 0)))

SPL4 = Handle_Geom_BSplineCurve_DownCast(SPL2_c.Translated(gp_Vec(10, 0, 0)))

Dont know if it is of any help :)

Commenter-1

04Author

Hi, Guido

Yes, just tried it and it works.

So casting works on the handles hierarchy, not on the actual objects

And it is actually static methods of [articular classes - OCC.Geom.Handle_Geom_BSplineCurve.DownCast etc

thank you

SP

05Commenter-2

Handle_Geom2d_Circle handle = DataExchange::circleToOCC(*this);

gp_Pnt2d pnt(point.x(), point.y());

bool flag = GeomLib_Tool::Parameter(handle, pnt, maxDist, u);

return flag;