Try this I had problems with using 'so in an automated way so this uses a pline as the reference. Else would have done a excel solution. using pline 'so !plent 20 3 30 3 30 -3 20 -3 C gets an error at command line.
You need to edit where a CSV file is saved.
Code:
; draw a pline at chainage and offsets from a pline
; By Alanh info@alanh.com.au
; June 2020
(defun pl-plbox ( / fname obj pt x ang )
(defun alg-ang (object pnt)
(angle '(0. 0. 0.)
(vlax-curve-getfirstderiv
object
(vlax-curve-getparamatpoint
object
pnt
)
)
)
)
; thanks to Lee-mac for this defun
; www.lee-mac.com
; 44 is comma
(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)
)
)
; Starts here
; 1st line in file is not required
(setq obj (vlax-ename->vla-object (car (entsel "Pick pline "))))
(setq fname (open (getfiled "Pick csv " "D:\\acadtemp\\" "csv" 8) "R"))
(princ (read-line fname))
(while (setq newline (read-line fname))
(setq lst (_csv->lst newline))
(setq x 0)
(command "_pline")
(while (= (getvar "cmdactive") 1 )
(repeat (/ (length lst) 2)
(setq pt (vlax-curve-getpointatdist obj (atof (nth x lst))))
(setq ang (- (alg-ang obj pt)(/ pi 2.0)))
(command (polar pt ang (atof (nth (+ x 1) lst))))
(setq x (+ x 2))
)
(command "c")
)
)
(close fname)
(princ)
)
(pl-plbox)