TheSwamp
CAD Forums => CAD General => Topic started by: Andrea on February 24, 2005, 10:21:52 PM
-
ok there is a good one...
when i open a new or existing drawing, and load some lisp files...
is there any way to see all active variables ?
eg:
if I load a lisp and in this lisp you have this code..
(setq var1 (getvar "textsizse")
var2 (getvar "dwgname")
)
and the var1 and/or var2 is not set to nil after or before loading the file...
so i would like to know how many variables not set to nil can i found.
something like (PRINT ALLVARS)
var1 = 1
var2 = "drawing1.dwg"
etc...
don't know if i'm clear... :oops:
-
Atoms16.vlx (http://www.theswamp.org/lilly_pond/mp/lisp/atoms16.vlx?nossi=1) (compiled w/AutoCAD 2004) is gettin' a bit long in the tooth but it may provide the kind of information you're looking for.
(http://www.theswamp.org/screens/mp/atoms.png) (http://www.theswamp.org/lilly_pond/mp/lisp/atoms16.vlx?nossi=1)
Failing the above it's a relatively simple matter to walk through the atoms-family and examine each symbol: is it an int, a real, a list, a string ... (be gentle I wrote this very quickly):
(defun FindSymbols
;;-----------------------------------------------------------------
;;
;; FindSymbols © 2005 Michael Puckett · All Rights Reserved
;;
;;-----------------------------------------------------------------
;;
;; Version · 1.0 2005/02/24 MP Original code.
;; 1.1 2005/02/25 MP Distilled / Recoded.
;;
;; About · FindSymbols is an atoms-family scanner that
;; allows one to scan for specific data types c/w
;; with include and exclude spec ability.
;;
;; Written · Quick and dirty for www.theswamp.org and friends.
;;
;; Contact · cadlabs@gmail.com
;;
;;-----------------------------------------------------------------
;;
;; examples
;;
;; (progn
;; (mapcar 'print
;; (FindSymbols
;; '(int real) ;; find numeric values
;; "*" ;; include everything
;; "vl*,ac*" ;; exclude vl*,ac*
;; )
;; )
;; (princ)
;; )
;;
;; (progn
;; (mapcar 'print
;; (FindSymbols
;; '(str) ;; find string values
;; "*" ;; include everything
;; "" ;; exclude nothing
;; )
;; )
;; (princ)
;; )
;;
;; (progn
;; (mapcar 'print
;; (FindSymbols
;; '(
;; safearray ;;
;; variant ;; find activex values
;; vla-object ;;
;; )
;; "*" ;; include everything
;; "" ;; exclude nothing
;; )
;; )
;; (princ)
;; )
;;
;; data returned
;;
;; (
;; (A INT 1)
;; (B INT 2)
;; (C INT 3)
;; ...
;; (PI REAL 3.14159)
;; )
;;
;;-----------------------------------------------------------------
( typeList
includeFilter
excludeFilter
/
GetSymbolProperties
)
(defun GetSymbolProperties ( symbol / value )
(list
symbol
(strcase (vl-symbol-name symbol))
(type (setq value (vl-symbol-value symbol)))
value
)
)
(if (null typeList)
(setq typeList
'( ename
exrxsubr
file
int
list
pagetb
pickset
real
safearray
str
subr
sym
usubr
variant
vla-object
)
)
)
(setq includeFilter
(if (/= 'str (type includeFilter))
"*"
(strcase includeFilter)
)
)
(setq excludeFilter
(if (/= 'str (type excludeFilter))
""
(strcase excludeFilter)
)
)
(mapcar
'(lambda (x) (list (car x) (caddr x) (cadddr x)))
(vl-sort
(vl-remove-if 'null
(mapcar
'(lambda ( properties / name )
(if (member (caddr properties) typeList)
(if (wcmatch
(setq name (cadr properties))
includeFilter
)
(if (not
(wcmatch
name
excludeFilter
)
)
properties
)
)
)
)
(mapcar 'GetSymbolProperties
(atoms-family 0)
)
)
)
'(lambda (a b) (< (cadr a) (cadr b)))
)
)
)
I've really got to get a life.
Edit 1: Revised code.
-
Type LSP at the command prompt. Hope this helps.
-
<Long quote back deleted>
Thanks...but i can't go to the link...
ask me for a login and password...
also...i got an error when tring the code...
??
-
The login username and password is the same one you use for theSwamp. :shock:
-
Thanks...but i can't go to the link...
ask me for a login and password...
also...i got an error when tring the code...
??
What whdjr said above.
Also, how are you using FindSymbols, it works for me at work and home, AutoCAD 2002 / 2004 respectively.
Try this --
(progn (mapcar 'print (FindSymbols '(int real) "*" "vl*,ac*")) (princ))
What happens?
-
thanks..
it work ! :wink:
-
You're welcome; cheers.