Author Topic: Creating rectangles in 3D from a CSV file  (Read 1519 times)

0 Members and 1 Guest are viewing this topic.

Robyn

  • Mosquito
  • Posts: 3
Creating rectangles in 3D from a CSV file
« on: September 12, 2023, 12:31:06 PM »
Hey everybody!

So I have am banging my head against a wall here. I'm trying to create a LISP that will read in sets of 3 numbers (a valid point) , then draws a polyline between those points in the order in which they were read in. Seems easy right?

"How bout no!"

I can get the lisp to read the CSV. I even got it to plot the points, but they were all on the same X axis. So I beseech the hive mind that is the swamp and call upon the elder gods and goddesses for assistance. Heck I'll even sacrifice a few digitizers it that will help.

I've attached my file below.

Thank you all in advance,

Robyn (Slowly going out of her mind)

VovKa

  • Water Moccasin
  • Posts: 1632
  • Ukraine
Re: Creating rectangles in 3D from a CSV file
« Reply #1 on: September 12, 2023, 01:59:06 PM »
looks like you've asked chatgpt first :)

Robyn

  • Mosquito
  • Posts: 3
Re: Creating rectangles in 3D from a CSV file
« Reply #2 on: September 12, 2023, 03:08:40 PM »
looks like you've asked chatgpt first :)

Yeah I did because I was trying to get it figured out. Sorry if that offended you or something.

BIGAL

  • Swamp Rat
  • Posts: 1444
  • 40 + years of using Autocad
Re: Creating rectangles in 3D from a CSV file
« Reply #3 on: September 12, 2023, 07:01:27 PM »
The open file appears correct, you just make a list of points by reading line by line then run a make pline. Some code to help. I am guessing its a csv file.

Code: [Select]
; thanks to Lee-mac for this defun
(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 lst (cons (csv->lst newline) lst))

Code: [Select]
(defun Polyline (lst)
   (entmakex (list (cons 0 "POLYLINE")
   (cons 10 '(0 0 0))))
   (mapcar
   (function (lambda (p)
   (entmake (list (cons 0 "VERTEX") (cons 10 p)))))
   lst)
   (entmakex (list (cons 0 "SEQEND")))
)

A man who never made a mistake never made anything