• This forum is the machine-generated translation of www.cad3d.it/forum1 - the Italian design community. Several terms are not translated correctly.

extract variable data in a text file

  • Thread starter Thread starter bnfnrc88
  • Start date Start date

bnfnrc88

Guest
Hello, everyone.
large lines I have created a lisp that allows to insert variables and then realize a design.
eventually save that design with a name like "r001.dwg".

I would like the lisp to generate automatically a "r001.txt" file with the variables I used and the values I attributed to them. in this way I can then check that data I entered at the time of compilation of the lisp.

do you know how to do it or if there is any valid alternative to this method?

:wink: thanks
 
in dwg you can use "user" variables to store data, or:

useri1 - useri2... useri5 for numbers interiors
userr1 - userr2... userr5 for numbers reali
users1 - users2 ....... users5 per strinkets

problem #1 - the number of variables is limited to 5 for each type of data.
problem n° 2 - while using and userr are saved in the dwg, users are not (who knows why).

If you want to save data on files, you place an example to save in same folder as the dwg un file con lo same name ma estensione txt.

the variables I have considered are:
(setq var1 45) -- > whole
(setq var2 189.23) --> real
(setq var3 "pluto") --> string

take a look at how I treated the different types of data, considering that at txt you can pass (and withdraw) only strings.
Code:
(defun scrivi_file (/ nomefile f)
    
    (vl-load-com)
    
    (setq nomefile (strcat (getvar "dwgprefix") (vl-filename-base (getvar "dwgname")) ".txt"))

    (setq f (open nomefile "w"))
    
    (write-line (rtos var1) f)   
    (write-line (rtos var2) f)   
    (write-line var3 f)
    
    (close f)

)
Code:
(defun playgi_file (/ nomefile f)

(vl-load-com)
(setq nomefile (strcat (getvar "dwgprefix") (vl fileame-base (getvar "dwgname"))) ".txt")
(setq f (open nomefile "r")
(if (/= f nil)
(progn

(setq was1 (atoi (read-line f))
(setq was2 (atof (read-line f)))
(setq was3 (read-line f)

(close f)
)
)
)
wanting to change folder replace the path in the construction of the filename.

:smile:
 

Forum statistics

Threads
44,997
Messages
339,767
Members
4
Latest member
ibt

Members online

No members online now.
Back
Top