- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello Everyone,
I have a friend that uses a lisp routine for many years and it worked great up until version 2016. He now changed job and is using version 2023 and the lisp does not work right. It loads normal but at a certain point it sould get information from a TXT file that is solicited but it does not. It opens the Atribute window and askes to input all the data (as shown on the image I uploaded).
The Lisp should create a block/attribute composed of a point, the point number (npunt), description of point (descrip) and point elevation (cota).
It gets the coordinates for the point from the TXT file but not the rest of the information.
This id the lisp file (I have also uploaded it)-
(defun PONTO()
(setq es (getreal "Denominador da escala, (so para o texto) <> :"))(terpri)
(setq al (getreal "Altura do texto em milimetros <> :"))(terpri)
(setq alt (/ (* al es) 1000)
d1 (+ 100 alt)
d2 (- 100 (/ alt 2))
d3 (+ d2 (* 1.5 alt))
d4 (- d2 (* 1.5 alt)))
(SETQ SIT (LIST D1 D2)
SITU (LIST D1 D3)
SI (LIST D1 D4))
(command "point" "100,100")
(command "layer" "M" "cota" "c" "1" "" "")
(command "attdef" "" "cota" "" "" SIT alt 0)
(command "layer" "M" "descrip" "c" "2" "" "")
(command "attdef" "i" "" "descrip" "" "" SITU "" "")
(command "layer" "M" "npunt" "c" "7" "" "")
(command "attdef" "" "npunt" "" "" SI "" "")
(command "zoom" "e")
(command "block" "pq" "100,100" "c" "0,0" "200,200" "")
)
(DEFUN c:IMPORTA()
(ponto)
(setq fname (getstring "Nome do ficheiro de pontos:?")
fhand (open fname "r"))
(if (null fhand) (print (strcat "Erro ao abrir o ficheiro " fname)))
(while (setq s (read-line fhand))
(setq npto (atoi (atoa))
X (atof (atoa))
Y (atof (atoa))
Z (atof (atoa))
descrip (atoa)
pin (list X Y 0)
Z (rtos Z 2 2))
(command "insert""pq" pin "" "" "" npto descrip Z)
)
)
(defun atoa(/ str2)
(setq str2 "")
(while (and (> (strlen s) 0) (= (substr s 1 1) " "))
(setq s (substr s 2 ))
)
(while (and (> (strlen s) 0) (/= (substr s 1 1) " "))
(setq str2 (strcat str2 (substr s 1 1))
s (substr s 2))
)
(setq s (substr s 2 ))
(eval str2)
)
(princ "Comece o programa com \"IMPORTA\"")
(PRINC)
The TXT file are sililar to this:
9001 -40647.112 191241.058 86.771 12
9002 -40639.561 191224.973 88.765 12
9003 -40624.827 191193.397 94.242 12.12
9004 -40652.837 191186.066 92.513 12
9005 -40666.340 191187.243 90.696 12
9006 -40688.441 191188.413 88.355 12
9007 -40712.070 191191.563 87.121 12
9008 -40732.718 191190.308 86.080 12
9009 -40752.407 191187.341 83.690 12.12
9010 -40752.390 191187.231 83.847 12.12
Fist is "NPUNT" , then x coordinate, then y coordinate, then "COTA", then "DESCRIP" seperated with a space
Any advice?
Solved! Go to Solution.