![]() Dim acadApp As AcadApplication Dim acadDoc As AcadDocument Dim LastRow As Long Dim acadPol As AcadLWPolyline Dim dblCoordinates() As Double Dim i As Long Dim j As Long Dim k As Long shCoordinates.Activate 'Find the last row. 'By Christos Samaras 'In order to use the macro you must enable the AutoCAD library from VBA editor: 'Go to Tools -> References -> Autocad xxxx Type Library, where xxxx depends 'on your AutoCAD version (i.e.ΔΆ010, 2011, 2012, etc.) you have installed to your PC. Option Explicit Option Private Module Sub DrawPolyline() 'Draws a polyline in AutoCAD using X and Y coordinates from sheet Coordinates. Although the example is quite simple, I think that it illustrates the general idea of using VBA from Excel to draw objects in AutoCAD. I thought that the interaction between Excel and AutoCAD using VBA might be useful for all types of engineers who using AutoCAD (primarily civil and surveying engineers), so I decided to post the VBA code that I wrote here. I manage to fulfill his request by using a lightweight polyline, which is a 2D line consisting of straight and arced segments. He had a large Excel file with points coordinates (x, y) and he wanted to connect them through a polyline to create a 2D profile. A friend of mine, who is surveying engineer, asked me recently if it is possible to draw a polyline in AutoCAD using coordinates from an Excel file. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |