In this post, we will learn how to draw arcs using pyautocad in Python (AddArc method). In one of our previous posts, we already demonstrated how we can draw circles using the AddCircle method, implementing pyautocad for AutoCAD in Python.

## 1. Importing necessary libraries: pyautocad, math

``````#Importing necessary methods from pyautocad library to draw a polygon:

#Importing math library:
from math import *``````

Alternatively, we can set the “create_if_not_exists” parameter to “True”. As a result, the code will generate an AutoCAD template which can then be stored locally on our machine.

``acad = Autocad(create_if_not_exists=True)``

## 3. Parameters for the command

With the specified pyautocad method AddArc, we need to pass certain parameters to draw an arc object.

Therefore, we need have to pass coordinates for the center point of the arc object, its radius, start angle, and end angle.

Syntax:

``````#Center Point
p1 = APoint(30,30)

The arc will be drawn counter-clockwise by autocad, starting from the x-axis of the 1st quadrant.

However, we can directly pass the center point coordinates to the command itself, with angles converting to radians from degrees, for instance.

``arc2 = acad.model.AddArc(APoint(45, 45), 10, 15*pi/180 , 105*pi/180)``

Now we are all set for creating an arc on the AutoCAD template. Refer to Figures 1.1 & 1.2.

## 4. Area of an arc object

In the case of open objects such as arcs, spline curves, and open polylines the area is computed as if a straight line connects the start point and endpoint of the arc.

To get the area of the arc object we will use the object.Area() method.

``````a1a = print("Area of Arc1 = " + str(round(arc1.Area,2)))
a2a = print("Area of Arc2 = " + str(round(arc2.Area,2)))

O/p:
Area of Arc1 = 133.79
Area of Arc2 = 28.54``````

Refer to Figures 2.1 & 2.2.

## 5. Other properties of an arc object

We can find more such properties related to an arc object. For example, center point, radius, start & endpoints, start and end angles, etc. as described below:

``````#Center of Arc
a1c = print("Center of Arc1 = " + str(arc1.Center))
a2c = print("Center of Arc2 = " + str(arc2.Center))

#Start & End points of Arc
a1sp = print("Start point of Arc1 = " + str(arc1.StartPoint))
a1ep = print("End point of Arc1 = " + str(arc1.EndPoint))
a2sp = print("Start point of Arc2 = " + str(arc2.StartPoint))
a2ep = print("End point of Arc2 = " + str(arc2.EndPoint))

#Start & End angles of Arc
a1sa = print("Start angle of Arc1 = " + str(arc1.StartAngle))
a1ea = print("End angle of Arc1 = " + str(arc1.EndAngle))
a2sa = print("Start angle of Arc2 = " + str(arc2.StartAngle))
a2ea = print("End angle of Arc2 = " + str(arc2.EndAngle))

O/p:
Center of Arc1 = (30.0, 30.0, 0.0)
Center of Arc2 = (45.0, 45.0, 0.0)

Start point of Arc1 = (37.5, 30.0, 0.0)
End point of Arc1 = (25.09767284352291, 24.323981285190538, 0.0)
Start point of Arc2 = (54.65925826289068, 47.588190451025206, 0.0)
End point of Arc2 = (42.411809548974794, 54.65925826289068, 0.0)

Start angle of Arc1 = 0.0
End angle of Arc1 = 4.0
Start angle of Arc2 = 0.2617993877991494
End angle of Arc2 = 1.8325957145940461``````

Refer to Figures 1.1 & 1.2 for verifying the output.

## You May Also Like

### Visualization of SimPy parking lot simulation results

Tekoha says:

Thank you so much!

Fernandp says:

Thanks Tanmay for this contribution, I am Fernando from Mexico, and I will use it within my CNC project. Congratulations for your technical and programiing skills.

Matt Johnson says:

I want to create a polyline that contains an arc. Is this possible?

Yes, see how to draw polyline in pyautocad

Matt Johnson says:

I see instructions on how to create a polyline from a list line endpoints:

points = [(0, 0), (10, 0), (10, 10), (0, 10)]