In our previous blog post from this series of pyautocad blogs, we discussed rectangular arrays. Now in this blog post, we will discuss polar arrays.
1. Setting up the work environment
As usual, we will set up our work environment by importing the pyautocad library to make AutoCAD interact with python.
from pyautocad import Autocad, APoint, aDouble from math import * acad = Autocad(create_if_not_exists=True)
2. Creating an object
To create an array, we will use the circle as an object. We will draw the circle using the AddCircle method. Also, we will store this circle in a variable “c1” to apply the array command against the created circle.
c1 = acad.model.AddCircle(APoint(100, 100), 100)
3. Working of polar array
AutoCAD determines the distance from the array’s center point to a reference point on the last object selected. The reference point used depends on the type of object previously selected. AutoCAD uses the center point of a circle or arc, the insertion point of a block or shape, the start point of the text, and one endpoint of a line or trace.
4. Creating polar array
Before creating the polar array, let’s check the syntax for creating the polar array.
# Syntax: object.ArrayPolar(NumberOfObjects, AngleToFill, CenterPointofArray) # Angle shall be specified in radians # Center point of array shall be specified in the form of three-element array of doubles
Using the above-mentioned syntax, we will create the array.
arr1 = c1.ArrayPolar(10, round(pi*180/180), aDouble(550, 600, 0))
For more information on AutoCAD itself, you can also review the Autodesk documentation.
Civil engineer interested in automation in core subjects such as civil, mechanical and electrical, using IT skills comprising cloud computing, devops, programming languages and databases along with the technical skills gained while working as a civil engineer since past 3 years.