AutoCAD macro to Extract Area of Polygons and Polylines

Extract Area of Circles

Join online Course on AutoCAD VBA Programming

Following is the VBA code to extract Area of Polygons and Polylines in AutoCAD drawings.

Sub ExtractAreaOfPolygonsAndPlines_1()
Open “E:DetailsOfPolygonsAndPlines.txt” For Output As 1
Dim XLnCADObject As AcadObject
Dim XLnCADPline As AcadLWPolyline
For Each XLnCADObject In ThisDrawing.ModelSpace
If XLnCADObject.ObjectName = “AcDbPolyline” Then
Set XLnCADPline = XLnCADObject
X = XLnCADPline.Coordinates(0)
Y = XLnCADPline.Coordinates(1)
Print #1, “X,Y-” & X; “,” & Y
Print #1, “Area-” & XLnCADPline.Area; “”
End If
Next
Close (1)
End Sub

Join online Course on Scripting in AutoCAD


Macros (VBA for AutoCAD)

Scripting in AutoCAD

Tips & Tricks in AutoCAD