Author Topic: see the variables  (Read 3720 times)

0 Members and 1 Guest are viewing this topic.

Andrea

  • Water Moccasin
  • Posts: 2372
see the variables
« 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:
Keep smile...

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
see the variables
« Reply #1 on: February 25, 2005, 01:04:01 AM »
Atoms16.vlx (compiled w/AutoCAD 2004) is gettin' a bit long in the tooth but it may provide the kind of information you're looking for.



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):

Code: [Select]
(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.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Russ

  • Guest
see the variables
« Reply #2 on: February 25, 2005, 08:57:47 AM »
Type LSP at the command prompt. Hope this helps.

Andrea

  • Water Moccasin
  • Posts: 2372
see the variables
« Reply #3 on: February 25, 2005, 09:46:37 AM »
Quote from: MP
<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...

??
Keep smile...

whdjr

  • Guest
see the variables
« Reply #4 on: February 25, 2005, 10:32:56 AM »
The login username and password is the same one you use for theSwamp. :shock:

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
see the variables
« Reply #5 on: February 25, 2005, 11:43:17 AM »
Quote from: Andrea
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?
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Andrea

  • Water Moccasin
  • Posts: 2372
see the variables
« Reply #6 on: February 27, 2005, 06:12:42 PM »
thanks..

it work ! :wink:
Keep smile...

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
see the variables
« Reply #7 on: March 04, 2005, 06:05:50 PM »
You're welcome; cheers.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst