I want to draw lines, circles, arcs and other standard entities in c# like in AutoLisp. E.g. in AutoLisp you can draw circles via 3 points on its circumference. But in .Net API there is only constructor via center and radius. So if I have 3 point on circumference I have to calculate the center and radius the same way it makes Autocad. So I have to copy the logic already exists. Is there any libs doing that or maybe I miss something?
Hi,
In any language while trying to draw a circle, logically you need a center point & radius or Diameter to create a circle and also you need two points to draw a line as well in any other languages.
If you don't want to use the constructor just create an instance of a class (suppose a Circle ) then Center then Radius , layer , color .... etc.
Since the circle constructor does not have an overload that accepts three points you will have to use the CircularArc3d which does accept three points. So do something like this.
public Circle CircleByCircumference(Point3d point1, Point3d point2, Point3d point3) { // Create a temporary CircularArc3d by three points // and use it to create our Circle CircularArc3d circularArc3d = new CircularArc3d(point1, point2, point3); Circle circle = New Circle(); circle.Center = ca.Center; circle.Normal = ca.Normal; circle.Radius = ca.Radius; return circle; }
I did this off the top of my head so there might be errors but that is the general gist of it.
The documentation indicates you cannot use that constructor to build a full circle. But there is a Set(...) method that takes three points as arguments, so perhaps its possible to call that post-creation.
Well, it was untested! This should work i think.
public Circle CircleByCircumference(Point3d point1, Point3d point2, Point3d point3) { // Create a temporary CircularArc3d by three pointsand use it to create the Circle using CircularArc3d circularArc3d = new CircularArc3d(point1, point2, point3); { return new Circle(circularArc3d.Center, circularArc3d.Normal, circularArc3d.Radius) } }