remember lisp variables after closing acad?

Hello
This is working perfekt but how to make it remember the last number after
closing and opening acad and current drawing??
Peeter
Try pasting the following into a text document, then save as "your file
> name.lsp", then in ACAD at the "Command:" prompt type in: (load "your file
> name") , then type in: nmbr
>
> ;;;;begin code by Jeff Mishler to insert
> ;;;;a number and increment the value to insert
> ;;;;the next number
>
> (defun c:nmbr (/ new_num)
> (if (not *last_num*)(setq *last_num* 1))
> (cond
> ((setq new_num (getint
> (strcat "\nNumber to start numbering with ("
> (itoa *last_num*)
> ") : ")))(start_lbl))
> ((setq new_num *last_num*)(start_lbl))
> )
> (princ)
> )
> (defun start_lbl (/ CURHGT CURSTYL INSPT)
> (setq curStyl (tblsearch "style" (getvar "textstyle")))
> (if (= 0 (cdr (assoc 40 curStyl)))
> (progn
> (initget 7)
> (setq curHgt (getreal "\nEnter a height for the text: "))
> )
> (setq curhgt (cdr (assoc 40 curStyl)))
> )
> (while (setq insPt (getpoint "\nSelect next number Insertion Point: "))
> (entmake (list '(0 . "TEXT")
> '(100 . "AcDbEntity")
> (cons 8 (getvar "clayer"))
> '(100 . "AcDbText")
> (cons 10 insPt)
> (cons 40 curhgt)
> (cons 1 (itoa new_num))
> '(50 . 0)
> (cons 7 (getvar "textstyle"))
> )
> )
> (setq new_num (1+ new_num)
> *last_num* new_num
> )
> )
> )
> ;;;;;end code
Reply to
Peeter
Loading thread data ...
If it is the same drawing you wish to remember the number then you can use one of the users vars. It been awhile but I think the syntax is (setvar uservar value) where uservar is user1, user2 Hello
Reply to
gjs
Well ... sort of. The User Variables are USERI1 - USERI5 (integers), USERR1 - USERR5 (reals), and USERS1 -USERS5 (strings). USERRn and USERIn values are stored in the .dwg file, but USERSn values are not. And the syntax is (for example):
(setvar "USERI1" value) and (setq value (getvar "USERI1")) ___
Reply to
Paul Turvill
Does AutoCAD support SETENV and GETENV like LT does? Then you can save values in the registry insead of in the dwg.
Conny
"Paul Turvill" skrev i meddelandet news: snipped-for-privacy@corp.supernews.com...
Reply to
Conny Klasson
Not as native commands, but as LISP expressions:
(setenv "MyVariable" "MyValue") and (getenv "MyVariable")
I mentioned this possibility in my earlier post to this thread. ___
Reply to
Paul Turvill

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.