Author Topic: creating a longitudinal profile in autocad using a lisp file  (Read 7398 times)

0 Members and 1 Guest are viewing this topic.

Penny

  • Guest
creating a longitudinal profile in autocad using a lisp file
« on: February 20, 2006, 08:37:34 AM »
Hi All :-)

I was wondering if anyone can help me? I've located a lisp file (dc_lsec) that enables me, as the heading above describes, to plot a longitudinal section of ground level and chainage automatically. I need to type in the levels and chainages within autocad though, which then creates a *.dat file. Is there any routine that allows me to bring in my own *.dat file with the relevant chainage and g/elevations in it already that bypasses me having to type it in autocad?

Would really appreciate any help  ;-)

penny

Peter Jamtgaard

  • Guest
Re: creating a longitudinal profile in autocad using a lisp file
« Reply #1 on: February 20, 2006, 08:49:45 AM »
If the data in the dat file is a comma delimited text file this function will import it as a list of sublists, that can be manipulated to drawing objects.

(csvfiletolist "c:/acad/mydatafile.data" ",")

Peter

Code: [Select]
; Import a CSV File to a list of Sublists

(defun csvFiletoList (strFilename strChar / lstOfSublists strText z)
 (setq z (open strFilename "r"))
 (while (setq strText (read-line z))

  (setq lstOfSublists (cons (CSVStringToList strText strChar) lstOfSublists))
 )
 (close z)
 (reverse lstOfSublists)
)

; Parsing a textstring to a list.

(defun CSVStringToList  (strText strChar / intPosition lstStrings)
 (while (setq intPosition (vl-string-search strChar strText 0))
  (setq lstStrings  (cons (substr strText 1 intPosition) lstStrings)
        strText     (substr strText (+ intPosition 1 (strlen strChar)))
  )
 )
 (reverse (cons strText lstStrings))
)

Penny

  • Guest
Re: creating a longitudinal profile in autocad using a lisp file
« Reply #2 on: February 20, 2006, 10:56:38 AM »
Hi Peter

Thanks for your help! Unfortunately i'm really quite new to autocad and am not too sure how to use the function. The lisp file attached (dc_lsec.lsp) below is what i've been using though I have approximately 660 points to type in manually which i'd prefer not to do in autocad. Can I instead copy and paste your function instead of using the code written under ";Create file of chainage and contour level" in the dc_lsc.lsp code where i can then locate my comma delimited file that i've created?

really appreciate all your help ;-)
penny

If the data in the dat file is a comma delimited text file this function will import it as a list of sublists, that can be manipulated to drawing objects.

(csvfiletolist "c:/acad/mydatafile.data" ",")

Peter

Code: [Select]
; Import a CSV File to a list of Sublists

(defun csvFiletoList (strFilename strChar / lstOfSublists strText z)
 (setq z (open strFilename "r"))
 (while (setq strText (read-line z))

  (setq lstOfSublists (cons (CSVStringToList strText strChar) lstOfSublists))
 )
 (close z)
 (reverse lstOfSublists)
)

; Parsing a textstring to a list.

(defun CSVStringToList  (strText strChar / intPosition lstStrings)
 (while (setq intPosition (vl-string-search strChar strText 0))
  (setq lstStrings  (cons (substr strText 1 intPosition) lstStrings)
        strText     (substr strText (+ intPosition 1 (strlen strChar)))
  )
 )
 (reverse (cons strText lstStrings))
)