Tue, 06/13/2017 - 21:49
Forums:
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
Attachments:
Wed, 06/14/2017 - 11:34
Hi Severin,
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, Guido
Wed, 06/14/2017 - 22:39
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
Thu, 06/15/2017 - 12:11
Hi Severin,
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 :)
Guido
Thu, 06/15/2017 - 21:35
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
Wed, 12/26/2018 - 10:54
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;