RuiCris Posted November 6, 2023 Share Posted November 6, 2023 (edited) 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? Importa.lsp Edited November 6, 2023 by SLW210 Added Code Tags! Quote Link to comment Share on other sites More sharing options...
BIGAL Posted November 6, 2023 Share Posted November 6, 2023 (edited) Pt num bubble.lspHave a look at attached may be helpful about making the block pq. Re read a line I use a Lee-mac function. ;; String to List - Lee Mac ;; Separates a string using a given delimiter ;; str - [str] String to process ;; del - [str] Delimiter by which to separate the string ;; Returns: [lst] List of strings (defun LM:str->lst ( str del / pos ) (if (setq pos (vl-string-search del str)) (cons (substr str 1 pos) (LM:str->lst (substr str (+ pos 1 (strlen del))) del)) (list str) ) ) (setq lst (LM:str->lst str " ")) (setq lst (LM:STR->LST str " ")) ("9001" "-40647.112" "191241.058" "86.771" "12") then just use the values in the list, (nth 0 lst) (nth 1 lst) and so on. Also check Attreq variable it stops or allows attribute entry. Edited November 6, 2023 by BIGAL Quote Link to comment Share on other sites More sharing options...
mrharris78 Posted November 7, 2023 Share Posted November 7, 2023 (edited) Removed - already addressed by BIGAL (Attreq) Edited November 7, 2023 by mrharris78 Removed - already addressed by BIGAL (Attreq) Quote Link to comment Share on other sites More sharing options...
RuiCris Posted November 7, 2023 Author Share Posted November 7, 2023 Thanks everyone, problem fixed, just had to set attdia to 0 then it runs great and set it back to 1 after Quote Link to comment Share on other sites More sharing options...
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.