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

0 Members and 1 Guest are viewing this topic.

ribarm

  • Water Moccasin
  • Posts: 1776
  • 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

  • Gator
  • Posts: 3101
  • I don't need a job, I need Money!!
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??)
"A language that doesn’t have everything is actually easier to program in than some that do."

        — Dennis M. Ritchie

Master_Shake

  • Swamp Rat
  • Posts: 1339
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

  • Water Moccasin
  • Posts: 1776
  • 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

  • SuperMod
  • Swamp Rat
  • Posts: 1041
  • 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

Sometimes the question is more important than the answer.

ribarm

  • Water Moccasin
  • Posts: 1776
  • 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: 798
  • 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

  • Water Moccasin
  • Posts: 1776
  • 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: 798
  • 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: 887
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

  • Water Moccasin
  • Posts: 1776
  • 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: 17194
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 »
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox | About

MP

  • Seagull
  • Posts: 17194
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 »
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox | About

ronjonp

  • Needs a day job
  • Posts: 6584
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 10 x64 - AutoCAD /C3D 2018

Custom Build PC

rkmcswain

  • Swamp Rat
  • Posts: 887
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!