rookie37 Posted September 18, 2008 Posted September 18, 2008 I need to input coordinates from a text file I wrote a lisp but I'm sure there is a much easier/cleaner way to do the same This inserts a block I type in excel 479.61 on a column and 22 in another I then glue these two together as (COMMAND "-insert" "lsection" "479.61,22.00" "" "" "") (DEFUN C:555 () (COMMAND "-insert" "lsection" "479.61,22.00" "" "" "") (COMMAND "-insert" "lsection" "596.51,22.00" "" "" "") (COMMAND "-insert" "lsection" "611.69,22.00" "" "" "") (COMMAND "-insert" "lsection" "620.42,22.00" "" "" "") (COMMAND "-insert" "lsection" "638.62,22.00" "" "" "") ) Quote
rkmcswain Posted September 18, 2008 Posted September 18, 2008 Give this a shot: (setq fp (open "c:\\coords.txt" "r") lst '() i 0) (while (setq a (read-line fp)) (setq lst (cons a lst)) ) (close fp) (repeat (length lst) (command "._insert" "lsection" (nth i lst) "" "" "") (setq i (1+ i)) ) Quote
borgunit Posted September 18, 2008 Posted September 18, 2008 http://www.cadtutor.net/forum/showthread.php?t=25204 Quote
rookie37 Posted September 18, 2008 Author Posted September 18, 2008 Give this a shot: (setq fp (open "c:\\coords.txt" "r") lst '() i 0) (while (setq a (read-line fp)) (setq lst (cons a lst)) ) (close fp) (repeat (length lst) (command "._insert" "lsection" (nth i lst) "" "" "") (setq i (1+ i)) ) Thank you! this saved me a day or two of work How do I change this to look at 2 files? c:\\xcoords.txt" c:\\ycoords.txt" or (probably better. don't know if it is practical/possible) have my text file look like x 165.26 164.37 332.58 412.40 y 21.00 21.00 21.00 21.00 instead of 165.26,21.00 164.37,21.00 332.58,21.00 412.40,21.00 Quote
bsamc2000 Posted September 25, 2008 Posted September 25, 2008 You can also leave it as an Excel file and open it throught VBA or Dot Net. If no one posts it first I will post tomorrow. Quote
bsamc2000 Posted September 26, 2008 Posted September 26, 2008 Try this. It should allow you to pick from a list of existing blocks and select an Excel file to retrieve the points list from. Sorry about the lack of comments in the coding but I hope it helps. Points.zip Quote
rookie37 Posted September 28, 2008 Author Posted September 28, 2008 Thank you very much for your help. I'm always amazed at the help here. It's sometimes better than a paid service. It also embarrases me a bit. You have gone through all this work and I know nothing about VBA. I have never used it but I'll probably figure it out. However I don't know how to edit it or taylor it to my needs. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.