Required a lsp to make automatic topo survey by creating layer point text from one excel

Required a lsp to make automatic topo survey by creating layer point text from one excel

sdhara.hit
Advocate Advocate
2,237 Views
28 Replies
Message 1 of 29

Required a lsp to make automatic topo survey by creating layer point text from one excel

sdhara.hit
Advocate
Advocate

Required a autocad lsp that can create text and point from excel file also make sure that text & point will be in same layer as text value or mention layer name. also need to crate that layer name from excel. Its to make automatic topo survey.

0 Likes
2,238 Views
28 Replies
Replies (28)
Message 21 of 29

autoid374ceb4990
Collaborator
Collaborator

What exactly does "2d topo survey" look like?  The data you posted has no elevation data. If you just want 2D points drawn that should be no problem.

0 Likes
Message 22 of 29

pendean
Community Legend
Community Legend

@sdhara.hit wrote:

Its too much high level thinking....


pendean_0-1720533562894.png

 

0 Likes
Message 23 of 29

diagodose2009
Collaborator
Collaborator

Using Excel directly,  is very hard, because today exists too many version CAD program/s (Cadian, AutoCad, TurboCad) and parser coordinates from *excel to Drawing.CAd.; is too hard for everyone.

Only AutoCAd have between 70...100 versions Acad, and compatibility with MsExcel

is bad-lock for All.

M/r. sdhara.hit do not need import Excel .coo to Drawing, and extend Excel function/s

with  surveyour's hi-tech-function/s.

 [code]

My solution I can parser Excel coordinates files as profesionally surveyour, for she.

https://youtu.be/hrW-o7Ln4EA

https://youtu.be/AyqJf8csmXk

If she need, then she send PM tom me, perhaps together can research our'solutions.

[/code]

 

 

 

 

 

0 Likes
Message 24 of 29

autoid374ceb4990
Collaborator
Collaborator

If the OP has Excel the XLS file can be saved as a CSV (comma delimited) file to be read easily by a LISP program.  Also the coordinate file the OP posted contains layer names with a space.  I am using a really old version of AutoCAD (R14) and spaces are not allowed in layer names, perhaps this is not true in later versions??

 

diagodose2009i: how do you calculate volumes with no Z coordinates?
0 Likes
Message 25 of 29

john.uhden
Mentor
Mentor

@autoid374ceb4990 ,

I think Excel provides the choice of a tab or a comma as a delimiter when creating a .CSV, so not to worry about spaces.

John F. Uhden

0 Likes
Message 26 of 29

Sea-Haven
Mentor
Mentor

Ok simplest way is read Excel direct, then insert a block with attributes, easy done. 

 

Again post a Excel we should not have to dummy up data for testing. 

 

What to you want at insertion point, a "Point" a "X" etc.

0 Likes
Message 27 of 29

sdhara.hit
Advocate
Advocate

How can I delete this post? I want to draw just point. but from excel . with same layer define in excel in AutoCAD.

 

 

 

 

To write an AutoCAD LISP program that draws points from Excel and ensures the points are placed on the same layer as described in the Excel file, you can follow these steps. This involves reading data from an Excel file, extracting point coordinates and layer information, and then drawing points on the specified layers in AutoCAD.

First, ensure you have the required Excel file. The file should have the coordinates and layer information in columns. For example, let's assume the Excel file has the following columns:

  • X: X-coordinate of the point
  • Y: Y-coordinate of the point
  • Z: Z-coordinate of the point (optional, can be set to 0 if not used)
  • Layer: Layer name for the point

Here's the LISP program to achieve this:

 

lisp
Copy code

(defun c:DrawPointsFromExcel ()
;; Function to read data from Excel and draw points in AutoCAD
(defun ReadExcelData (filePath / excelApp workbook worksheet rows data)
(setq excelApp (vlax-get-or-create-object "Excel.Application"))
(vlax-put-property excelApp 'Visible :vlax-false)
(setq workbook (vlax-invoke-method excelApp 'Workbooks 'Open filePath))
(setq worksheet (vlax-get-property workbook 'ActiveSheet))
(setq rows (vlax-get-property worksheet 'UsedRange))
(setq data (vlax-get-property rows 'Value2))
(vlax-invoke-method workbook 'Close :vlax-false)
(vlax-release-object workbook)
(vlax-release-object excelApp)
data
)

;; Function to draw a point in AutoCAD
(defun DrawPoint (x y z layerName)
(command "._-LAYER" "M" layerName "")
(setvar "clayer" layerName)
(command "._POINT" (list x y z))
)

;; Main function to read Excel data and draw points
(defun DrawPointsFromExcelMain ()
(setq filePath (getfiled "Select Excel File" "" "xlsx;xls" 0))
(if filePath
(progn
(setq excelData (ReadExcelData filePath))
;; Assuming the first row is headers, so start from the second row
(setq rowCount (length excelData))
(setq i 2)
(while (<= i rowCount)
(setq row (nth (1- i) excelData))
(setq x (atof (nth 0 row)))
(setq y (atof (nth 1 row)))
(setq z (atof (nth 2 row)))
(setq layerName (nth 3 row))
(DrawPoint x y z layerName)
(setq i (1+ i))
)
)
)
(princ)
)

;; Execute the main function
(DrawPointsFromExcelMain)
(princ)
)

 

How to Use the LISP Program

  1. Save the LISP code above into a file with the .lsp extension, e.g., DrawPointsFromExcel.lsp.
  2. Open AutoCAD.
  3. Load the LISP program using the APPLOAD command.
  4. Run the program by typing DrawPointsFromExcel in the command line.
  5. Select the Excel file when prompted.

 

 

But chat gpt lsp code not working.

0 Likes
Message 28 of 29

sdhara.hit
Advocate
Advocate

sample excel

0 Likes
Message 29 of 29

autoid374ceb4990
Collaborator
Collaborator

So now your Excel file does not have point names?

I have an old LISP program that I wrote many years ago that will read your file, but you would have to save the XLS file as a CSV ( space delimited text file) for it to work.  Send me a private message if you are interested. 

0 Likes