Jul 23, 2010 topic: excel points to autocad Posted: 22.Jul.2010 at 18:19 I have about 10,000 points(x,y,z) in excel that i need to polt in Autocad with the elevations labled(z) on the drawing.With plotting of the points i am ok, but how do i show this elevations(z) withot entering them one by one. Introduction During the previous weekend, a blog reader (Denis) sent me an email asking me if it is possible to draw points in AutoCAD from Excel. The answer is quite straightforward and is YES. The proposed solution involves the AddPoint method: RetVal = object.AddPoint(Point) Where: RetVal: Point object. The newly created Point object. Object: ModelSpace Collection, PaperSpace Collection, Block – the objects this method applies to. Point: Variant (three-element array of doubles); input-only. The coordinates of the point to be created. The sample workbook that you will find in the Downloads section below requires three main user inputs: the coordinates of the point (in X, Y, Z), the point type (select from a dropdown list) and the point size. Then, by clicking the “Add Point(s)” button the points are created either in the active drawing (if AutoCAD is already launched), or in a newly created drawing. The picture below summarizes the available point types (you will find the picture also in the sample workbook). Note: I would like to clarify that all the VBA codes presented in this blog do NOT work with AutoCAD LT. AutoCAD LT does NOT support VBA. Use a full AutoCAD version instead. VBA code The code is actually a loop; most of the code is used for initializing the AutoCAD object, as well as the active/new drawing. Option Explicit Sub DrawPoints() '-------------------------------------------------------------------------------------------------- 'Draws points in AutoCAD using data - point coordinates, type and size - from Excel. 'The code uses late binding, so no reference to external AutoCAD (type) library is required. 'It goes without saying that AutoCAD must be installed at your computer before running this code. 'Written by: Christos Samaras 'Date: 'e-mail: [email protected] 'site: '-------------------------------------------------------------------------------------------------- 'Declaring the necessary variables. Dim acadApp As Object Dim acadDoc As Object Dim acadCircle As Object Dim LastRow As Long Dim i As Long Dim Point(0 To 2) As Double 'Activate the coordinates sheet and find the last row. With Sheets( 'Coordinates').Activate LastRow =.Cells(.Rows.Count, 'A').End(xlUp).Row End With 'Check if there are coordinates for at least one point.
0 Comments
Leave a Reply. |