Jump to content

Recommended Posts

Posted (edited)

please help me write a code. i have csv file contains point, northing, easting, elevation, description. i also have a drawing file that has attributes-point,description,elevation. this drawing file is in a support file search path. i want to make an autolisp that import csv data into autocad. The northing and easthing will be the location of the point.

NANCSV.DWG SURVEY POINTS.csv

1.JPG

2.JPG

Edited by NanGlase
Posted

Not sure what you are meaning it changes the coordinates, are X and Y coordinates interchanged? (CAD is off - holiday - so not checking), if you selected the Y - Coordinate button but pointed it to the X and vice versa would it work OK?

 

There are plenty of 'read CSV Lisps' or "Read Text File' Lisps out there if you want to use one of them as a basis though

  • Like 1
Posted (edited)

This is like part one of a two part question. I may be wrong and only points wanted.

 

Part one import csv file, inserting blocks, code is out there.

 

Part two string all the points using the description, yes use CIV3D or Stringer or Civil Site Design. Also includes step one.

 

Yes have looked at stringing points. There is another post and out there and a couple of people are looking at the stringing function.

 

Anyway try this. I made a block called SurvPoint which is made up of a POINT and your attdef's.

(defun c:survpoints ( / fname dummy pts newline)

; thanks to Lee-mac for this defun comma is 44
(defun csv->lst ( str / pos )
(if (setq pos (vl-string-position 44 str))
    (cons (substr str 1 pos) (csv->lst (substr str (+ pos 2))))
    (list str)
    )
)

(setq fname (open (getfiled "Pts FILES" "d:\\" "csv" 16) "R"))
(setq dummy (read-line fname)) ; throw away 1st line
(while (setq newline (read-line fname))
  (setq pts (csv->lst newline))
  (command "-insert" "SurvPoint" (list (atof (nth 1 pts))(atof (nth 2 pts))) 1 1 0
  (nth 3 pts)  (last pts)(nth 0 pts))
)
(close fname)

(princ)
)

Please note don't need a csv can read excel direct.

Edited by BIGAL
  • Like 1
Posted
36 minutes ago, BIGAL said:

This is like part one of a two part question. I may be wrong and only points wanted.

 

Part one import csv file, inserting blocks, code is out there.

 

Part two string all the points using the description, yes use CIV3D or Stringer or Civil Site Design. Also includes step one.

 

Yes have looked at stringing points. There is another post and out there and a couple of people are looking at the stringing function.

 

Anyway try this. I made a block called SurvPoint which is made up of a POINT and your attdef's.

(defun c:survpoints ( / fname dummy pts newline)

; thanks to Lee-mac for this defun comma is 44
(defun csv->lst ( str / pos )
(if (setq pos (vl-string-position 44 str))
    (cons (substr str 1 pos) (csv->lst (substr str (+ pos 2))))
    (list str)
    )
)

(setq fname (open (getfiled "Pts FILES" "d:\\" "csv" 16) "R"))
(setq dummy (read-line fname)) ; throw away 1st line
(while (setq newline (read-line fname))
  (setq pts (csv->lst newline))
  (command "-insert" "SurvPoint" (list (atof (nth 1 pts))(atof (nth 2 pts))) 1 1 0
  (nth 3 pts)  (last pts)(nth 0 pts))
)
(close fname)

(princ)
)

Please note don't need a csv can read excel direct.

thanks a lot. Happy new year!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...