Jump to content

Need help for this lisp routine, what input it requires.


faisal

Recommended Posts

(defun c:bhy()

(setvar "cmdecho" 0)

(graphscr)

(setq fd (open "c:\\CAD\\BHY.txt" "r")

info (read-line fd)

)

(while (/= info nil)

(setq eas (atof (substr info 4 13))

nor (atof (substr info 15 12))

ipt (list eas nor)

fi (atoi (substr info 27 3))

ba (atof (substr info 31 3))

x (fix ba)

y (fix (* (- ba x)10))

xs (itoa x)

ys (itoa y)

)

(command "insert" "Bathy" ipt 1 1 0 xs ys fi)

(setq info (read-line fd))

)

(close fd)

(princ)

)

Link to comment
Share on other sites

718230.9 2141655.86 79.7

718230.72 2141666.48 79.6

718230.6 2141678.3 79.53

718230.39 2141689.31 79.44

718230.44 2141700.79 79.34

718230.69 2141711.85 79.24

718230.8 2141722.4 79.16

718230.86 2141732.27 79.13

718230.35 2141742.55 79.07

718229.81 2141752.45 78.95

718229.05 2141763.07 78.82

718228.39 2141773.71 78.69

718228.33 2141784.11 78.59

718228.14 2141794.83 78.58

718227.65 2141804.88 78.43

718227.19 2141815.69 78.44

718226.83 2141826.63 78.44

718226.48 2141836.53 78.44

 

this is what i hve made and i think that this one s wrong

Link to comment
Share on other sites

If you don't know how to use the lisp and what input is required for it I suggest you don't use it and find another lisp.

 

Are you trying to insert a block at E, N and elevation?

Link to comment
Share on other sites

actually i know that this lisp import xyz and its fix nos. as block attributes with metres and decimetres.

Link to comment
Share on other sites

i dont know how to make this one as per the lisp

 

Each line of text in the file needs to be at least 33 characters long.

The variable EAS starts with the fourth character and is 13 characters long. That's how you read the (substr info 4 13)

The last variable being set by each line BA is 3 characters long starting with the 31st character. It is then turned into a floating number.

Link to comment
Share on other sites

I would think that the lisp is not correct. It seems to be looking for a space delineated file, and the one posted is certainly not in that format.

 

Following on from LibertyOne's post, the variable "eas" starts at character 4 and is 13 characters long, so it ends at character 16. The variable "nor" starts at character 15, but this overlaps the characters from variable "eas", so is patently nonsense. :cry:

 

You must try to find out the correct code and the correct format data file.

Link to comment
Share on other sites

If the text file is indeed on that format, what you can do is convert it to list

 

"718230.9 2141655.86 79.7"

 

 (read (strcat "(" "718230.9 2141655.86 79.7" ")"))

 

(718231.0 2.14166e+006 79.7)

 

 

 
(defun c:bhy  (/ fd info pts)
     (setvar "cmdecho" 0)
     (setq fd (open "D:\\BHY.txt" "r"))
     (while (setq info (read-line fd))
           (setq pts (strcat "(" info ")"))
           (command "_insert" "Bathy" "_non" (read pts) 1 1 0)
;;; Block attribute edit here;;;;;
           )
     (close fd)
     )

 

Hope this helps

:)

 

Edit: Reading the other thread, I suspect your Bathy block includes attributes, we can re-write it to input data into the attributes.

Edited by pBe
Link to comment
Share on other sites

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