Author Topic: display or inspect all defined commands inside AutoCAD session  (Read 10946 times)

0 Members and 1 Guest are viewing this topic.

ribarm

  • Gator
  • Posts: 3249
  • Marko Ribar, architect
display or inspect all defined commands inside AutoCAD session
« on: January 29, 2018, 05:35:13 AM »
Greetings...

I have a question about seeing or exporting complete list of commands that are built in, or that are added as custom ones inside active AutoCAD session... I know how to review loaded lisp definitions through (atoms-family) function, but I don't know how to inspect built in or added commandmethods C# dll definitions which are loaded through NETLOAD command... Any insight or thought is welcome...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

MickD

  • King Gator
  • Posts: 3636
  • (x-in)->[process]->(y-out) ... simples!
Re: display or inspect all defined commands inside AutoCAD session
« Reply #1 on: January 29, 2018, 02:57:06 PM »
for C# you can use reflection, here might be a good place to start https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/attributes/accessing-attributes-by-using-reflection

for the host application I think you would need to use ARX to get hold of the command stack as I don't think this is exposed in .net (it's been a while so it might be now??)
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

ChrisCarlson

  • Guest
Re: display or inspect all defined commands inside AutoCAD session
« Reply #2 on: January 29, 2018, 03:25:25 PM »
You can read the acad.pgp and compare against an OOTB AutoCAD installation?

ribarm

  • Gator
  • Posts: 3249
  • Marko Ribar, architect
Re: display or inspect all defined commands inside AutoCAD session
« Reply #3 on: March 04, 2018, 12:36:47 PM »
You can read the acad.pgp and compare against an OOTB AutoCAD installation?

Maybe dummy question, but are all built-in commands listed in pgp file no matter what ACAD vertical/vanilla is used?
Still I don't know how to get NETLOAD and other definitions defined outside (atoms-family), but never mind for that - I am searching for answer on my just asked question...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2132
  • class keyThumper<T>:ILazy<T>
Re: display or inspect all defined commands inside AutoCAD session
« Reply #4 on: March 04, 2018, 09:31:37 PM »
Try these;
Read the prompts ...


C:\Program Files\Autodesk\AutoCAD 2018\Express\lspdata.lsp

C:\Program Files\Autodesk\AutoCAD 2018\Express\acadinfo.lsp
Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

ribarm

  • Gator
  • Posts: 3249
  • Marko Ribar, architect
Re: display or inspect all defined commands inside AutoCAD session
« Reply #5 on: March 05, 2018, 05:04:39 AM »
You can read the acad.pgp and compare against an OOTB AutoCAD installation?

Maybe dummy question, but are all built-in commands listed in pgp file no matter what ACAD vertical/vanilla is used?
...

I need an answer to my question - Yes or No...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

huiz

  • Swamp Rat
  • Posts: 917
  • Certified Prof C3D
Re: display or inspect all defined commands inside AutoCAD session
« Reply #6 on: March 05, 2018, 07:29:14 AM »
You can read the acad.pgp and compare against an OOTB AutoCAD installation?

Maybe dummy question, but are all built-in commands listed in pgp file no matter what ACAD vertical/vanilla is used?
...

I need an answer to my question - Yes or No...




If you want a clear answer: No, the PGP file does not contain a list of alle available commands.


As far as I know there is also not something available that shows a list of all internal commands, all aliases, every loaded Lisp, .NET and ARX function.


Why do you need that list anyway?

The conclusion is justified that the initialization of the development of critical subsystem optimizes the probability of success to the development of the technical behavior over a given period.

ribarm

  • Gator
  • Posts: 3249
  • Marko Ribar, architect
Re: display or inspect all defined commands inside AutoCAD session
« Reply #7 on: March 05, 2018, 08:15:49 AM »
Why do you need that list anyway?

To learn what ACAD can do and to study and research perhaps other possibilities of CAD while programming...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

huiz

  • Swamp Rat
  • Posts: 917
  • Certified Prof C3D
Re: display or inspect all defined commands inside AutoCAD session
« Reply #8 on: March 05, 2018, 09:18:10 AM »
Well, if you want a full list of all AutoCAD commands, you can download the contents of each page listed here:


http://www.cadforum.cz/cadforum_en/command.asp



The conclusion is justified that the initialization of the development of critical subsystem optimizes the probability of success to the development of the technical behavior over a given period.

rkmcswain

  • Swamp Rat
  • Posts: 978
Re: display or inspect all defined commands inside AutoCAD session
« Reply #9 on: March 05, 2018, 09:27:27 AM »
I don't know if this will help you, but run the ARX command, "C" option.

For best results:
1. Run LOGFILEON
2. Seq QAFLAGS to 2
3. Run ARX, option "C".
4. Run LOGFILEOFF
5. Set QAFLAGS back to 0
6. Open the logfile.

ribarm

  • Gator
  • Posts: 3249
  • Marko Ribar, architect
Re: display or inspect all defined commands inside AutoCAD session
« Reply #10 on: March 05, 2018, 10:25:41 AM »
I don't know if this will help you, but run the ARX command, "C" option.

For best results:
1. Run LOGFILEON
2. Seq QAFLAGS to 2
3. Run ARX, option "C".
4. Run LOGFILEOFF
5. Set QAFLAGS back to 0
6. Open the logfile.

Fantastic, thanks many many thanks...
Incredible trick...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: display or inspect all defined commands inside AutoCAD session
« Reply #11 on: March 05, 2018, 12:09:18 PM »
Nice tip RK. Quick code to exploit:

Code: [Select]
(defun c:commands ( / :setvars :main )

    ;;==========================================================================
    ;;  Commands.lsp
    ;;--------------------------------------------------------------------------
    ;;  \|//  1.02 2018-03-07
    ;;  |Oo|  © 2018 Michael Puckett Some Rights Reserved.
    ;;  |- |  mp@cadanalyst.org
    ;;--------------------------------------------------------------------------
    ;;  1.01  2018-03-05. MP. Initial code.
    ;;  1.02  2018-03-07. MP. Modularized.
    ;;--------------------------------------------------------------------------
   
    (defun :setvars ( lst )
        ;;  Send a cons-pair or cons-pairs lists of (varname . varvalue).
        ;;  eg (setq restore (ue2-setvars '((CMDECHO . 0)(REGENMODE 0))))
        ;;  Returns original values in the same cons-pair construct.
        ;;  >> ((CMDECHO . 1) (REGENMODE . 1))               
        (mapcar
            (function
                (lambda ( p / k r )
                    (setq r (cons (setq k (car p)) (vl-catch-all-apply 'getvar (list k))))
                    (vl-catch-all-apply 'setvar (list k (cdr p)))
                    r
                )
            )
            (if (vl-list-length lst)
                lst
                (list lst)
            )
        )
    )
   
    (defun :main ( / restore flag handle stream lst name )
   
        (setq restore
            (:setvars
               '(   (cmdecho     . 0)
                    (logfilemode . 1)
                    (qaflags     . 2)
                )
            )
        )

        (setq flag (strcat "START CAPTURE: " (rtos (getvar 'cdate) 2 8)))
        (princ (strcat "\n" flag))
        (command ".arx" "_commands")

        (setq handle (open (getvar 'logfilename) "r"))
        (while (setq stream (read-line handle))
            (setq lst (cons stream lst))
        )
        (close handle)
       
        (:setvars restore)
   
        (setq lst (cddr (member flag (reverse lst))))
        (while (eq "" (vl-string-trim " \t\n" (car lst)))
            (setq lst (cdr lst))
        )
       
        (setq
            name   (vl-filename-mktemp "commands.txt")
            handle (open name "w")
        )
        (foreach x lst (princ (strcat x "\n") handle))   
        (close handle)
       
        (startapp "notepad.exe" name)
   
        (princ)
       
    )
   
    (:main)           

)

Cheers.
« Last Edit: March 07, 2018, 08:12:52 PM by MP »
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: display or inspect all defined commands inside AutoCAD session
« Reply #12 on: March 05, 2018, 12:12:17 PM »
And the predictable:

Code: [Select]
(defun c:Vars ( / :pad :matching-vars :get-spec :main )

    ;;==========================================================================
    ;;  Vars.lsp
    ;;--------------------------------------------------------------------------
    ;;  \|//  1.07 2018-03-07
    ;;  |Oo|  © 2018 Michael Puckett Some Rights Reserved.
    ;;  |- |  mp@cadanalyst.org
    ;;--------------------------------------------------------------------------
    ;;  1.01  2018-03-05. MP. Initial code.
    ;;  1.02  2018-03-05. MP. Apply constant width to var name column.
    ;;  1.03  2018-03-05. MP. Use getvar instead of capturing screen; no truncation.
    ;;  1.04  2018-03-06. MP. Improve speed: only initial run abuses the log file.
    ;;  1.05  2018-03-06. MP. Add undocumented vars.
    ;;  1.06  2018-03-06. MP. Flag vars in :undocumented that return nil.
    ;;  1.07  2018-03-07. MP. Fixed a missing local declaration.
    ;;--------------------------------------------------------------------------

    (if

        (null
            (vl-every
                (function (lambda (x) (eq 'str (type x))))
                (if (eq 'list (type *getvar-names*)) *getvar-names* '(0))
            )
        )

        ;;  Function get-var-names is defined locally but has and needs global
        ;;  scope. Don't understand why? <trump> Sad! </trump>.

        (defun get-var-names ( / :car-str :unique :undocumented :setvars :main )

            (defun :car-str ( text / lst )
                (substr
                    (setq text (strcase (vl-string-trim " \t\r\n" text)))
                    1
                    (-  (length (setq lst (vl-string->list text)))
                        (length (member 32 lst))
                    )
                )
            )

            (defun :unique ( lst / result )
                (foreach x lst
                    (or
                        (member x result)
                        (setq result (cons x result))
                    )
                )
                (reverse result)
            )

            ;;  Thanks to Owen Wengerd & the internet ...

            (defun :undocumented ( )
               '(   "_LINFO"                ;; Returns nil in 2018, may remove.
                    "_PKSER"
                    "_SERVER"
                    "_VERNUM"
                    "ADCSTATE"
                    "AECENABLEASSOCANCHOR"
                    "AECENABLESECTIONCLEANUP"
                    "AECVCOMPAREIGNOREHATCH"
                    "AECVCOMPAREIGNORETEXT"
                    "AECVCOMPARENEWCOLOR"
                    "AECVCOMPAREOLDCOLOR"
                    "AECVCOMPAREUNCHANGEDCOLOR"
                    "APBOX"
                    "AUXSTAT"
                    "AXISMODE"              ;; Returns nil in 2018, may remove.
                    "AXISUNIT"
                    "BS_BITS"               ;; Returns nil in 2018, may remove.
                    "CLEARTYPE"
                    "CPUTICKS"
                    "DBCSTATE"
                    "DBGLISTALL"            ;; Returns nil in 2018, may remove.
                    "EDITDELETIONEFFECT"    ;; Returns nil in 2018, may remove.
                    "ENTEXTS"
                    "ENTEXTS"
                    "ENTMODS"
                    "FILETABVISIBLE"
                    "FLATLAND"
                    "FORCE_PAGING"
                    "FORCE_PAGING"
                    "GLOBCHECK"
                    "ISFLIPARC"
                    "JWDEBUG"               ;; Returns nil in 2018, may remove.
                    "KESDEBUG"              ;; Returns nil in 2018, may remove.
                    "LAZYLOAD"
                    "LAZYLOAD"
                    "LENGTHENTYPE"
                    "MILLISECS"
                    "NFWSTATE"
                    "NODENAME"
                    "NOMUTT"
                    "OPMSTATE"
                    "OSNAPNODELEGACY"
                    "PHANDLE"
                    "POINTCLOUDEVENTLOG"
                    "POINTCLOUDPERFTRACK"
                    "POINTCLOUDPROGRESSIVEUPDATE"
                    "PRESELECTIONEFFECTTEST"
                    "PRESELECTIONNOTIFICATION"
                    "PRODUCT"
                    "PROGRAM"
                    "QAFLAGS"
                    "QAUCSLOCK"
                    "SHORTCUTMENU"
                    "SMJOURNAL"
                    "SMTHREADHOTMODE"
                    "SMUNFIXEDTRANSFORM"
                    "SPACESWITCH"
                )
            )

            (defun :setvars ( lst )
                ;;  Send a cons-pair or cons-pairs lists of (varname . varvalue).
                ;;  eg (setq restore (ue2-setvars '((CMDECHO . 0)(REGENMODE 0))))
                ;;  Returns original values in the same cons-pair construct.
                ;;  >> ((CMDECHO . 1) (REGENMODE . 1))               
                (mapcar
                    (function
                        (lambda ( p / k r )
                            (setq r (cons (setq k (car p)) (vl-catch-all-apply 'getvar (list k))))
                            (vl-catch-all-apply 'setvar (list k (cdr p)))
                            r
                        )
                    )
                    (if (vl-list-length lst)
                        lst
                        (list lst)
                    )
                )
            )

            (defun :main ( / restore flag handle stream lst )

                (setq restore
                    (:setvars
                       '(   (cmdecho     . 0)
                            (logfilemode . 1)
                            (qaflags     . 2)
                        )
                    )
                )

                (setq flag (strcat "START CAPTURE: " (rtos (getvar 'cdate) 2 8)))
                (princ (strcat "\n" flag))
                (command ".setvar" "_?" "*")

                (setq handle (open (getvar 'logfilename) "r"))
                (while (setq stream (read-line handle))
                    (setq lst (cons stream lst))
                )
                (close handle)

                (:setvars restore)

                (setq lst (cdr (member flag (reverse lst))))
                (while (eq "" (vl-string-trim " \t\n" (car lst)))
                    (setq lst (cdr lst))
                )

                (mapcar 'cadr
                    (vl-sort
                        (mapcar
                            (function (lambda (x) (list (strcase x t) x)))
                            (:unique
                                (append
                                    ;;  add any vars AutoCAD may not normally include
                                    (:undocumented)
                                    (mapcar ':car-str lst)
                                )
                            )
                        )
                        (function (lambda (a b) (< (car a) (car b))))
                    )
                )
            )

            ;;  The following is tempting but lisp cries because of the size of
            ;;  the list.
            ;;
            ;;      (eval (list 'defun 'get-var-names symbol nil (:main)))
            ;;
            ;;  The following isn't sexy but it's reliable as long as no one
            ;;  abuses the global:

            (setq *getvar-names* (:main))

            (defun get-var-names ( ) *getvar-names*)

            *getvar-names*

        )
    )

    (defun :pad ( text len )
        (while (< (strlen text) len)
            (setq text (strcat text " "))
        )
        text
    )

    (defun :matching-vars ( spec )
        (vl-remove-if-not
            (function (lambda (x) (wcmatch x spec)))
            (get-var-names)
        )
    )

    (defun :get-spec ( / spec )
        (if
            (eq ""
                (setq spec
                    (strcase
                        (getstring "\nEnter search pattern <*>: ")
                    )
                )
            )
            "*"
            spec
        )
    )

    (defun :main ( / spec vars len name handle )

        (cond

            (   (null (setq vars (:matching-vars (setq spec (:get-spec)))))
                (princ (strcat "\nNo variables matched pattern '" spec "'."))
            )

            (   (setq
                    len    (1+ (apply 'max (mapcar 'strlen vars)))
                    name   (vl-filename-mktemp "vars.txt")
                    handle (open name "w")
                )

                (princ (strcat "Variables matching pattern '" spec "':\n\n") handle)

                (foreach var vars
                    (princ
                        (strcat
                            (:pad var len)
                            (vl-prin1-to-string (getvar var))
                            "\n"
                        )
                        handle
                    )
                )

                (close handle)

                (startapp "notepad.exe" name)

            )

        )

        (princ)

    )

    (:main)

)

Cheers.
« Last Edit: March 07, 2018, 08:10:21 PM by MP »
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

ronjonp

  • Needs a day job
  • Posts: 7527
Re: display or inspect all defined commands inside AutoCAD session
« Reply #13 on: March 07, 2018, 12:16:50 PM »
Very nice as always Michael :)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

rkmcswain

  • Swamp Rat
  • Posts: 978
Re: display or inspect all defined commands inside AutoCAD session
« Reply #14 on: March 07, 2018, 12:20:47 PM »
Very nice as always Michael :)

Ditto that!

huiz

  • Swamp Rat
  • Posts: 917
  • Certified Prof C3D
Re: display or inspect all defined commands inside AutoCAD session
« Reply #15 on: March 07, 2018, 03:26:14 PM »
Cool  :mrgreen:
The conclusion is justified that the initialization of the development of critical subsystem optimizes the probability of success to the development of the technical behavior over a given period.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: display or inspect all defined commands inside AutoCAD session
« Reply #16 on: March 07, 2018, 08:13:39 PM »
Thanks guys!  :-)

PS: Both updated (why in code comments).
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Grrr1337

  • Swamp Rat
  • Posts: 812
(apply ''((a b c)(a b c))
  '(
    (( f L ) (apply 'strcat (f L)))
    (( L ) (if L (cons (chr (car L)) (f (cdr L)))))
    (72 101 108 108 111 32 87 111 114 108 100)
  )
)
vevo.bg

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: display or inspect all defined commands inside AutoCAD session
« Reply #18 on: March 08, 2018, 06:45:56 PM »
If you like c:vars may like what i did to abuse it in version 2.02.

(not posted yet)

O.o
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: display or inspect all defined commands inside AutoCAD session
« Reply #19 on: March 08, 2018, 07:00:12 PM »
Quote from: Mae West
Of all the long things I've every tried --

-- this is the most recent.

Too long to post; attached.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

GDF

  • Water Moccasin
  • Posts: 2081
Re: display or inspect all defined commands inside AutoCAD session
« Reply #20 on: March 28, 2018, 08:23:15 AM »
Quote from: Mae West
Of all the long things I've every tried --

-- this is the most recent.

Too long to post; attached.

Awesome

Could this be modified to get only global setq vars?
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

GDF

  • Water Moccasin
  • Posts: 2081
Re: display or inspect all defined commands inside AutoCAD session
« Reply #21 on: March 28, 2018, 09:32:22 AM »
Got this to work...

Code: [Select]
(defun VARLISTIT  ()
  (textpage)
  (foreach
         n  '(ARCH#LOGO ARCH#YEAR ARCH#LTYP ARCH#UNIT ARCH#DECI ARCH#DDEC ARCH#ALDR ARCH#SYMS
              ARCH#ANNO ARCH#TEXT ARCH#PROJ ARCH#DIAL ARCH#CMDN ARCH#POSX ARCH#POSY ARCH#DIAP
              ARCH#LOOP ARCH#CLAY ARCH#LREA ARCH#MECH ARCH#CIVL ARCH#_CMM ACAD#PATH ARCH#BROW
              ARCH#DIRL ARCH#CUSN ARCH#LOGF ARCH#CUSF ARCH#MASF ARCH#CSTF ARCH#BLKF ARCH#FONF
              ARCH#HELF ARCH#IMAF ARCH#PATF ARCH#PROF ARCH#SUPF ARCH#FILF ARCH#LAYF ARCH#DRAF
              ARCH#BLOF ARCH#DIMF ARCH#SYMF ARCH#ANNF ARCH#UTIF ARCH#SCAL ARCH#SCID ARCH#SCDS
              ARCH#SLTS ARCH#LTSD ARCH#PLTS ARCH#UNID ARCH#LUID ARCH#_SCF ARCH#SFIL ARCH#SLAY
              ARCH#SDRA ARCH#SBLO ARCH#SDIM ARCH#SSYM ARCH#SANN ARCH#SUTI ARCH#SARC ARCH#SSTR
              ARCH#SMEC ARCH#SELE ARCH#SCIV ARCH_XDPC ARCH#XDCN ARCH#XDAD ARCH#XDTP ARCH#XDWW
              ARCH#XDPR ARCH#PIDF ARCH#DPRE ARCH#FMSG ARCH#LMSG ARCH#WMSG ARCH#BMSG ARCH#DMSG
              ARCH#LMSG ARCH#AMSG ARCH#UMSG ARCH#NLAY ARCH#NPLT ARCH#LAYL ARCH#LAYR ARCH#IWID
              ARCH#PWID ARCH#ENTL ARCH#ENTN ARCH#HPSC ARCH#HPGP ARCH#HFAC ARCH#VHAT ARCH#PHAT
              ARCH#UNIT ARCH#CLAY ARCH#LTSS ARCH#DDEC ARCH#DECI ARCH#LTYP ARCH#LOOP ARCH#ALDR
              ARCH#TEXT ARCH#ANNO ARCH#SYMS ARCH#LREA ARCH#TXSD ARCH#TXSN ARCH#TXST ARCH#TXSS
              ARCH#TXSC ARCH#TXSA ARCH#TXNW ARCH#TXTW ARCH#TXNH ARCH#TXTH ARCH#TXTS ARCH#TXVS
              ARCH#TXFD ARCH#TXFN ARCH#TXFT ARCH#TXFS ARCH#TXFC ARCH#TXFA ARCH#SIZE ARCH#ANGL
              ARCH#JAMB ARCH#SILL ARCH#RPDX ARCH#WWID ARCH#CPNT ARCH#GPNT ARCH#STEP ARCH#SRIS
              ARCH#STRD ARCH#SCNT ARCH#SJST ARCH#SREQ ARCH#STEQ ARCH#STPT ARCH#DECK ARCH#CABW
              ARCH#BLKX ARCH#RDPX ARCH#F_ID ARCH#F_OD ARCH#DTLN ARCH#SHTN ARCH#REV# ARCH#LINI
              ARCH#LIBF ARCH#LCMD ARCH#LSLD ARCH#LACT ARCH#LCLR ARCH#_ADC ARCH#DVAR ARCH#PAUS
              ARCH#TEMP ARCH#TNUM ARCH#DOSD ARCH#DSNP ARCH#DBRK ARCH#DECP ARCH#DSTP ARCH#DALN
              ARCH#DSTP ARCH#_NIC ARCH#SSET ARCH#ELVH ARCH#ELVW ARCH#BORD ARCH#BLKN ARCH#STRG
              ARCH#UDLR ARCH#VIEW ARCH#RTOS ARCH#_STR ARCH#_DIS ARCH#_NB_ ARCH#_VH_ ARCH#NVAL
              ARCH#PROJ ARCH#PNAM ARCH#DATE ARCH#PNUM)   
    (progn (print n) (princ (eval n)))))
(VARLISTIT)
(princ)
[code/]
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: display or inspect all defined commands inside AutoCAD session
« Reply #22 on: March 28, 2018, 12:03:54 PM »
atoms-family != sysvars

That said perhaps this ...

Code: [Select]
(defun c:Globals ( / :varz :get-var-spec :get-val-spec :pad :matching-vars :matching-vals :setvars :ntos :substr :main )

    ;;==========================================================================
    ;;  Globals.lsp
    ;;--------------------------------------------------------------------------
    ;;  \|//  1.01 2018-03-28
    ;;  |Oo|  © 2018 Michael Puckett Some Rights Reserved.
    ;;  |- |  mp@cadanalyst.org
    ;;--------------------------------------------------------------------------
    ;;  1.01  2018-03-28. MP. Initial code.
    ;;--------------------------------------------------------------------------

    (defun :globals ( )
        (vl-sort (atoms-family 1) '<)
    )

    (defun :get-var-spec ( / spec )
        (if
            (eq ""
                (setq spec
                    (strcase
                        (getstring "\nEnter variable NAME search pattern <*>: ")
                    )
                )
            )
            "*"
            spec
        )
    )
   
    (defun :get-val-spec ( / spec )
        (if
            (eq ""
                (setq spec
                    (strcase
                        (getstring "\nEnter variable VALUE search pattern <*>: ")
                    )
                )
            )
            "*"
            spec
        )
    )

    (defun :pad ( text len )
        (while (< (strlen text) len)
            (setq text (strcat text " "))
        )
        text
    )   
   
    (defun :matching-vars ( spec )
        (vl-remove-if-not
            (function (lambda (x) (wcmatch x spec)))
            (:globals)
        )
    )
   
    (defun :matching-vals ( vars spec )
        (vl-remove-if-not
            (function (lambda (p) (wcmatch (strcase (cadr p)) spec)))
            (mapcar
                (function
                    (lambda ( v / v$ v! )
                        (list v
                            (vl-prin1-to-string
                                (if (member
                                        (setq v! (type (setq v$ (eval (read v)))))
                                       '(exrxsubr file pagetb subr usubr vla-object)
                                    )
                                    v!
                                    v$
                                )
                            )
                        )
                    )
                )
                vars       
            )
        )
    )
   
    (defun :setvars ( lst )
        ;;  Pass the function a cons-pair or a list of cons-pairs:
        ;;  >> (setq restore (:setvars '((CMDECHO . 0)(REGENMODE 0))))
        ;;  Returns original values in the same construct:
        ;;  >> ((CMDECHO . 1) (REGENMODE . 1))
        ;;  So you can do this later:
        ;;  >> (:setvars restore)
        (mapcar
            (function
                (lambda ( p / k r )
                    (setq r (cons (setq k (car p)) (vl-catch-all-apply 'getvar (list k))))
                    (vl-catch-all-apply 'setvar (list k (cdr p)))
                    r
                )
            )
            (if (vl-list-length lst)
                lst
                (list lst)
            )
        )
    )
   
    (defun :ntos ( x / r s )
        (setq
            r (:setvars '((dimzin . 8)))
            s (if (eq 'real (type x)) (rtos x 2 15) (itoa x))
            r (:setvars r)
        )
        s   
    )
   
    (defun :substr ( text a b / result n )
        (setq result (substr text a b))
        (cond
            (   (not (< (setq n (strlen result)) (strlen (substr text a))))
                result
            )
            (   (wcmatch (substr text a) "(*)")
                (strcat (substr result 1 (- n 5)) " ..." (chr 41))
            )
            (
                (strcat (substr result 1 (- n 4)) " ...")
            )
        )
    )

    (defun :main ( / restore var-spec val-spec vars-vals var val len name handle )

        (cond

            (   (null (setq vars (:matching-vars (setq var-spec (:get-var-spec)))))
                (princ (strcat "\nNo variables matched pattern '" var-spec "'."))
            )
           
            (   (null (setq vars-vals (:matching-vals vars (setq val-spec (:get-val-spec)))))
                (princ (strcat "\nNo values matched pattern '" val-spec "'."))
            )

            (   (setq
                    restore (:setvars '((dimzin . 0)(luprec . 8)(auprec . 8)))
                    len     (1+ (apply 'max (mapcar 'strlen (mapcar 'car vars-vals))))
                    name    (vl-filename-mktemp "vars.txt")
                    handle  (open name "w")
                )
               
                (princ
                    (strcat
                        "ACADVER: " (rtos (atof (getvar 'acadver)) 2 1)
                        ": Global variables matching (name|value) pattern ('" var-spec "'|'" val-spec "'):\n\n"
                    )
                    handle
                )
               
                (foreach lst vars-vals
                    (princ
                        (strcat
                            (:pad (setq var (car lst)) len)
                            (cond
                                ((null (setq val (eval (read var)))) "nil")
                                ((numberp val) (:ntos val))
                                ((:substr (cadr lst) 1 80))
                            )
                            "\n"
                        )
                        handle
                    )
                )
               
                (:setvars restore)

                (close handle)

                (startapp "notepad.exe" name)

            )

        )

        (princ)

    )
   
    (:main)
   
)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

GDF

  • Water Moccasin
  • Posts: 2081
Re: display or inspect all defined commands inside AutoCAD session
« Reply #23 on: March 28, 2018, 12:37:54 PM »
Thanks
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: display or inspect all defined commands inside AutoCAD session
« Reply #24 on: March 28, 2018, 03:45:37 PM »
ur welcome
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Grrr1337

  • Swamp Rat
  • Posts: 812
Re: display or inspect all defined commands inside AutoCAD session
« Reply #25 on: March 29, 2018, 05:48:27 AM »
atoms-family != sysvars

That said perhaps this ...


(apply ''((a b c)(a b c))
  '(
    (( f L ) (apply 'strcat (f L)))
    (( L ) (if L (cons (chr (car L)) (f (cdr L)))))
    (72 101 108 108 111 32 87 111 114 108 100)
  )
)
vevo.bg

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: display or inspect all defined commands inside AutoCAD session
« Reply #26 on: April 14, 2018, 03:09:00 AM »
Hanhphuc @cadtutor.net has come up with a different, more direct way, to retrieve these 'ARX' commands:
http://www.cadtutor.net/forum/showthread.php?103760-AutoCAD-built-in-command-list-with-AutoLISP&p=701145&viewfull=1#post701145

The code does not work on BricsCAD BTW. But I notice that not all commands are listed. So 'inspecting all defined commands', as per the tittle of this topic, is not possible with this approach it seems.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: display or inspect all defined commands inside AutoCAD session
« Reply #27 on: April 14, 2018, 12:28:00 PM »
Thanks, interesting thread too.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst