Jump to content

input coordinates from a text file


Recommended Posts

Posted

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" "" "" "")
)

Posted

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))
)

Posted
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

:shock:

 

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

Posted

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.

Posted

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

Posted

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.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...