For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings

 

Need to speed up your development?
Have a look at our:

Samples & Tools

 

Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

How to get parameters from the Geom_Curve(s) ?

Severin Pappadeux's picture
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: 
Guido van Hilst not specified's picture

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

Severin Pappadeux's picture

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

Guido van Hilst not specified's picture

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

Severin Pappadeux's picture

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