pythonocc-core icon indicating copy to clipboard operation
pythonocc-core copied to clipboard

Circle

Open sumanth0703 opened this issue 3 years ago • 3 comments

How to make a circle in Python OCC? It would be helpful if shown with a code using MakeArcOfCircle using two points. Any other code is also okay.

sumanth0703 avatar May 26 '22 09:05 sumanth0703

Here are a lot of constructors.

from OCC.GC import GC_MakeCircle
circle = GC_MakeCircle(...)

ageeye avatar May 29 '22 06:05 ageeye

Here are a lot of constructors.

from OCC.GC import GC_MakeCircle
circle = GC_MakeCircle(...)

Thank You for your reply, I am looking for a circle with a prescribed radius, is it possible to do that in OCC? In GC_MakeCircle(...) we can make a indefinite circle, but if I want it to have dimensions then what can be the process?

sumanth0703 avatar May 29 '22 09:05 sumanth0703

Full example for FreeCAD. I choose the constructor with center, normal of plane & radius. As previously said, it exits other constructor. You must choose the best one for you.

from OCC.Core.gp import gp_Pnt, gp_Dir
from OCC.Core.GC import GC_MakeCircle
from OCC.Core.BRepBuilderAPI import BRepBuilderAPI_MakeEdge

radius = 5.
circle = GC_MakeCircle(gp_Pnt(0,0,0), gp_Dir(0, 0, 1), radius).Value()
edge =  BRepBuilderAPI_MakeEdge(circle).Edge()

# display in Freecad
App.newDocument("TestCircle")
import Part
Part.show(Part.__fromPythonOCC__(edge))

ageeye avatar May 29 '22 12:05 ageeye