PDA

View Full Version : How do I use a Spreadsheet (X,Y,Z dims) to create 3D boxes?



Event
25th Apr 2006, 05:04 pm
Please help...

I have a long list spread sheet with four columns -

Name, X dim, Y dim, Z dim

It would take days to make each one into a 3d box, add its text name and make into a block.

Does anyone know a script that will do it for me?

They only need to be boxes, no fancy shapes. I do need the text to be associated with the box (in a block) so that I can move them around and edit them seperately.

THANK YOU,

Event

fuccaro
4th May 2006, 04:56 am
Save the Excel file in CSV format and use this lisp routine:

;Creates boxes and saves them as blocks.
;The dimensions and block names are read from a CSV file;
(defun c:boxblock( / file i j re red l bi bn osmode cmdecho)
(setq file (open (getfiled "Open CSV" "" "csv" 4) "r"))
(setq osmode (getvar "OSMODE")
cmdecho (getvar "CMDECHO")
j -1 re 0
l (read-line file))
(setvar "OSMODE" 0)
(setvar "CMDECHO" 0)
(while (or (zerop (setq j (1+ j))) (not (null l)))
(setq bi nil i 0 red nil)
(repeat (strlen l)
(if (= ";" (substr l (setq i (1+ i)) 1)) (setq bi (cons i bi))))
(command "box" "0,0,0" "l")
(setq i 3)
(repeat 3
(command (substr l (1+ (nth (setq i (1- i)) bi)) (if (zerop i) nil (- (nth (1- i) bi) (nth i bi) 1))))
)
(command "-block" (setq bn (substr l 1 (1- (nth 2 bi)))))
(if (tblsearch "BLOCK" bn) (progn
(setq re (1+ re)
red t)
(command "Yes")
)
)
(command "0,0,0" "l" "")
(princ (strcat "\n\t" (if red "redefined: " "imported: ") bn))
(setq l (read-line file))
)
(close file)
(setvar "OSMODE" osmode)
(setvar "CMDECHO" cmdecho)
(princ (strcat "\n------------\n" (itoa j) " block(s) imported. (Redefined:" (itoa re) ")"))
(princ)
)
Welcome in the forum!