PDA

View Full Version : Insert block using coordinates in a txt file


jmctamney
2007-03-13, 01:53 AM
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

aaronic_abacus
2007-03-13, 02:03 AM
Look into OPEN, WRITE-LINE, READ-LINE, and CLOSE.

Also post an example text file and block.

.T.
2007-03-13, 02:18 AM
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,

Can you post a sample of the data you are working with? It would be easier if we knew how the data is layed out. IE is it comma delimited, space delimited, etc, and does it include the block name.

jmctamney
2007-03-13, 12:38 PM
as it is right now, it's a .txt file with x&y coordinates, each on a single line separated by a comma. I don't know yet what I'll use for my block. I'm trying to coordinate column locations based on x,y coordinates provided by the architect

.T.
2007-03-13, 07:09 PM
as it is right now, it's a .txt file with x&y coordinates, each on a single line separated by a comma. I don't know yet what I'll use for my block. I'm trying to coordinate column locations based on x,y coordinates provided by the architect

You might be able to modify T.Willey's code from THIS THREAD (http://forums.augi.com/showthread.php?t=56012) to do what you want. Have a looka at it, then let us know if you need help doing that.

abdulhuck
2007-03-13, 08:11 PM
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")


(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