pythonocc-core
pythonocc-core copied to clipboard
Circle
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.
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?
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))