Originally Posted by
jmctamney
I have a text file with x & y coordinates and I need to insert a block for a column at each coordinate. I thought of writing a script file but quickly changed my mind when I found out there were over 100 coordinates. My next thought was lisp but I'm lisp challenged when it comes to accessing outside data. Can anyone give me some direction and to how I go about this, or better yet, a lisp or portion of one that can get me started?
Thanks
Hi,
The following piece of code will read the text file and insert the block as per the coordinates. All you need to substitute is the input file name with path and your block name. If the block name is not in the drawing, give path and file name for the wblock (eg "c:\\path\blockname.dwg")
Code:
(defun c:insertBlocks (/ txtFile xyData expertVar attreqVar)
(setq expertVar (getvar "expert"))
(setq attreqVar (getvar "attreq"))
(setvar "expert" 2)
(setvar "attreq" 0)
(setq txtFile (open "c:\\cad\\textfile.txt" "r")) ; give the path & file name of x,y data
(while (setq xyData (read-line txtFile))
(command "-insert" "blockName" xyData "1" "1" "0") ; substitute blockName with your block
)
(close txtFile)
(setvar "expert" expertVar)
(setvar "attreq" attreqVar)
(princ)
)
Regards,
Abdul Huck