.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Autocad .Net API entities constructors, drawing like in AutoLisp

5 REPLIES 5
Reply
Message 1 of 6
avalancher2
525 Views, 5 Replies

Autocad .Net API entities constructors, drawing like in AutoLisp

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?

5 REPLIES 5
Message 2 of 6
_Tharwat
in reply to: avalancher2

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.

 

 

Message 3 of 6
fieldguy
in reply to: avalancher2

Can you post the lisp code you are referring to?

Message 4 of 6
Keith.Brown
in reply to: avalancher2

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.

 

 

Message 5 of 6
dgorsman
in reply to: Keith.Brown

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.

----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
"I don't know" is the beginning of knowledge, not the end.


Message 6 of 6
Keith.Brown
in reply to: dgorsman

 

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)
       }
    }

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost