Author Topic: vlax-dump-object->List  (Read 698 times)

0 Members and 1 Guest are viewing this topic.

Grrr1337

  • Newt
  • Posts: 191
Re: vlax-dump-object->List
« Reply #15 on: December 15, 2016, 06:12:22 pm »
Don't know about awesome but I'm stubborn and determined.
IMO Thats a part from the definition of being awesome programmer.
The original was actually a dll I wrote using Visual Studio 6 enterprise. Mid 90's. It was slick and very graphical (icons for each data type) using a listview widget and was good for a couple versions, then knackered by Autodesk. Rewrote it in lisp exploiting a std type library dll. Worked for years then knackered again. Rewrote again in 2010 pure lisp. Fingers crossed its not knackered for awhile.
So you were rolling with a few languages, I thought once you started with one language you continue(d) with it.

Sounds interesting (for me - a person that never opened ACAD till 2010's)
I'm not gonna reveal when I was born to make you feel old, so Lets just say you are very experienced (append valuable).  :-o

MP

  • Seagull
  • Posts: 16890
  • brevity != aggression
Re: vlax-dump-object->List
« Reply #16 on: December 15, 2016, 06:50:13 pm »
Thanks for the complimentary thoughts. LISP was technically my fourth language if I get to count ladder logic. As for feeling old, worry not, the snow on the roof and sidewalk is a constant reminder. :cry:
\|// Set goal. Experiment tirelessly until
|oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox | About

MP

  • Seagull
  • Posts: 16890
  • brevity != aggression
Re: vlax-dump-object->List
« Reply #17 on: December 16, 2016, 01:52:36 am »
I remember a time when a whiff of a hint was appreciated.

don't get me started ....

The internet has become a demanding mistress?
\|// Set goal. Experiment tirelessly until
|oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox | About

kdub

  • SuperMod
  • Swamp Rat
  • Posts: 811
  • class keyThumper<T>:ILazy<T>
Re: vlax-dump-object->List
« Reply #18 on: December 16, 2016, 02:09:09 am »
I remember a time when a whiff of a hint was appreciated.

don't get me started ....

The internet has become a demanding mistress?

Essentially yes .. which is incredible since it is an object without volition.
called Kerry in my other life

Sometimes the question is more important than the answer.

Andrea

  • Water Moccasin
  • Posts: 2244
Re: vlax-dump-object->List
« Reply #19 on: December 16, 2016, 01:21:58 pm »
just showing where i'm going with this...
not finished yet,..to much idea on table..
:)



Keep smile...

MP

  • Seagull
  • Posts: 16890
  • brevity != aggression
Re: vlax-dump-object->List
« Reply #20 on: December 16, 2016, 01:24:41 pm »
Nicely done. Reminds me of my old dll version. But nicer.
\|// Set goal. Experiment tirelessly until
|oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox | About

MP

  • Seagull
  • Posts: 16890
  • brevity != aggression
Re: vlax-dump-object->List
« Reply #21 on: December 16, 2016, 01:28:06 pm »
Make sure it will also make a hard copy, I find it very useful:

================================================================================

<Dwg: OMG.dwg> <Object: AcDbPolyline "2BC9">

====================================== PROPERTIES ==============================

Application®                           <Object: IAcadApplication>
Area®                                  447.23669466
Closed                                 :vlax-false
Color                                  256
ConstantWidth                          1.0
Coordinate                             
Coordinates                            (438.02349191 103.48063257 438.02349191 ... 171.07034114)
Database®                              <Object: IAcadDatabase>
Document®                              <Object: IAcadDocument>
Elevation                              0.0
EntityTransparency                     "ByLayer"
Handle®                                "2BC9"
HasExtensionDictionary®                :vlax-false
Hyperlinks®                            <Object: IAcadHyperlinks>
Layer                                  "HIDDEN"
Length®                                84.48966663
Linetype                               "BYLAYER"
LinetypeGeneration                     :vlax-true
LinetypeScale                          1.0
LineWeight                             -1
Material                               "ByLayer"
Normal                                 (0.0 0.0 1.0)
ObjectID®                              49
ObjectID32®                            49
ObjectName®                            "AcDbPolyline"
OwnerID®                               48
OwnerID32®                             48
PlotStyleName                          "ByLayer"
Thickness                              0.0
TrueColor                              <Object: IAcadAcCmColor>
Visible                                :vlax-true
                                       
====================================== DXF DATA ================================

  -1                                   <Ename: LWPOLYLINE "2BC9">
   0                                   "LWPOLYLINE"
 330                                   <Ename: BLOCK_RECORD "86">
   5                                   "2BC9"
 100                                   "AcDbEntity"
  67                                   1
 410                                   "Layout1"
   8                                   "HIDDEN"
 100                                   "AcDbPolyline"
  90                                   6
  70                                   128
  43                                   1.0
  38                                   0.0
  39                                   0.0
  10                                   (438.02349191 103.48063257)
  40                                   1.0
  41                                   1.0
  42                                   0.0
  91                                   0
  10                                   (438.02349191 103.48063257)
  40                                   1.0
  41                                   1.0
  42                                   0.41421356
  91                                   0
  10                                   (443.02349191 108.48063257)
  40                                   1.0
  41                                   1.0
  42                                   0.0
  91                                   0
  10                                   (443.02349191 166.07034114)
  40                                   1.0
  41                                   1.0
  42                                   -0.41421356
  91                                   0
  10                                   (448.02349191 171.07034114)
  40                                   1.0
  41                                   1.0
  42                                   0.0
  91                                   0
  10                                   (459.2154867 171.07034114)
  40                                   1.0
  41                                   1.0
  42                                   0.0
  91                                   0
 210                                   (0.0 0.0 1.0)
                                       
====================================== METHODS =================================

AddRef                                 
AddVertex                              
ArrayPolar                             
ArrayRectangular                       
Copy                                   
Delete                                 
Erase                                  
Explode                                
GetBoundingBox                         
GetBulge                               
GetExtensionDictionary                 
GetIDsOfNames                          
GetTypeInfo                            
GetTypeInfoCount                       
GetWidth                               
GetXData                               
Highlight                              
IntersectWith                          
Invoke                                 
Mirror                                 
Mirror3D                               
Move                                   
Offset                                 
QueryInterface                         
Release                                
Rotate                                 
Rotate3D                               
ScaleEntity                            
SetBulge                               
SetWidth                               
SetXData                               
TransformBy                            
Update
                                 
\|// Set goal. Experiment tirelessly until
|oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox | About

Andrea

  • Water Moccasin
  • Posts: 2244
Re: vlax-dump-object->List
« Reply #22 on: December 16, 2016, 02:09:12 pm »
Yes,...Thank you..is on the list..

if you notice,...when I clic on some #<Variant.... I use functions to get result..
so,..I'll do same thing for many other selection, like showing directly some info in AutoCAD.
I want to add also to allow to modify few value.. :)
Keep smile...

MP

  • Seagull
  • Posts: 16890
  • brevity != aggression
Re: vlax-dump-object->List
« Reply #23 on: December 16, 2016, 03:00:13 pm »
Thanks, did notice the mouse gesturing :) and best of luck with editing properties -- it can become a rabbit hole of validation.
\|// Set goal. Experiment tirelessly until
|oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox | About

Grrr1337

  • Newt
  • Posts: 191
Re: vlax-dump-object->List
« Reply #24 on: January 08, 2017, 06:06:30 am »
I really liked LM's suggestion, but was annoyed that it crashes on LWPOLYLINES / SPLINES, because of a properties with values of "...Indexed contents not shown...", so I performed the following modification (the hammer approach):

Code - Auto/Visual Lisp: [Select]
  1. (if (eq 'VLA-OBJECT (type obj))
  2.  (append
  3.    (list
  4.      (mapcar
  5.        (function
  6.          (lambda ( prp / prpval )
  7.            (if (not (vl-catch-all-error-p (setq prpval (vl-catch-all-apply 'vlax-get (list obj prp)))))
  8.              (list prp prpval)
  9.              (list prp nil)
  10.            )
  11.          )
  12.        )
  13.        (_GetObjectProperties obj)
  14.      )
  15.    )
  16.    (if mth (list (_GetObjectMethods obj)))
  17.  )
  18. )
  19.  

Soo for example when you have such property:
Code: [Select]
;   Coordinate = ...Indexed contents not shown...The list will turn it to:
Code: [Select]
("Coordinate" nil)
HTH, sorry for bumping this thread.

mailmaverick

  • Bull Frog
  • Posts: 317
Re: vlax-dump-object->List
« Reply #25 on: January 08, 2017, 10:24:16 am »
Courtesy Forum Members, my Code :

Code: [Select]
(defun c:LM_DumpObject (/ prop&methods)
  ;; Dumps Selected Object in a DCL Box having two List Boxes, one containing Object Properties and second containing Object Methods
  ;; Courtesy Lee Mac
  ;; Source : https://www.theswamp.org/index.php?topic=52409.0
  (vl-load-com)
  ;| -------------------------------------------------------------------------
------------------------------------------------------------------------------
          FUNCTION DEFINITIONS       
------------------------------------------------------------------------------
------------------------------------------------------------------------------
  |;
  ;;
  (defun vlax-dump-object->list (obj mth)
    (if (eq 'VLA-OBJECT (type obj))
      (append (list
                (mapcar (function
                          (lambda (prp / prpval)
                            (if (not (vl-catch-all-error-p (setq prpval (vl-catch-all-apply 'vlax-get (list obj prp)))))
                              (list prp prpval)
                              (list prp nil)
                            )
                          )
                        )
                        (_GetObjectProperties obj)
                )
              )
              (if mth
                (list (_GetObjectMethods obj))
              )
      )
    )
  )
  ;;
  (defun _GetObjectProperties (obj)
    (vl-remove-if-not (function (lambda (prp) (vlax-property-available-p obj prp))) (_GetVlaProperties))
  )
  ;;
  (defun _GetObjectMethods (obj)
    (vl-remove-if-not (function (lambda (mth) (vlax-method-applicable-p obj mth))) (_GetVlaMethods))
  )
  ;;
  (defun _GetVlaAtoms ()
    (eval (list 'defun
                '_GetVlaAtoms
                '()
                (list 'quote
                      (vl-sort (vl-remove-if-not
                                 (function (lambda (sym) (wcmatch (vl-symbol-name sym) "vla`-*")))
                                 (atoms-family 0)
                               )
                               (function (lambda (a b) (< (vl-symbol-name a) (vl-symbol-name b))))
                      )
                )
          )
    )
    (_GetVlaAtoms)
  )
  ;;
  (defun _GetVlaProperties ()
    (eval
      (list 'defun
            '_GetVlaProperties
            '()
            (list 'quote
                  (mapcar (function (lambda (sym) (substr (vl-symbol-name sym) 9)))
                          (vl-remove-if-not
                            (function (lambda (sym) (wcmatch (strcase (vl-symbol-name sym)) "VLA`-GET`-*")))
                            (_GetVlaAtoms)
                          )
                  )
            )
      )
    )
    (_GetVlaProperties)
  )
  ;;
  (defun _GetVlaMethods ()
    (eval
      (list 'defun
            '_GetVlaMethods
            '()
            (list 'quote
                  (mapcar (function (lambda (sym) (substr (vl-symbol-name sym) 5)))
                          (vl-remove-if
                            (function (lambda (sym) (wcmatch (strcase (vl-symbol-name sym)) "VLA`-GET`-*,VLA`-PUT`-*")))
                            (_GetVlaAtoms)
                          )
                  )
            )
      )
    )
    (_GetVlaMethods)
  )
  ;;
  (defun LM:ListBox2 (lis1 lis2 / DCH DCL DES)
    ;; Makes two List Boxes, each filled with supplied lists
    ;; lis1 : List1 to be appended in Left List Box
    ;; lis2 : List2 to be appended in Right List Box
    (defun *error* (msg)
      (if (and (= 'int (type dch)) (< 0 dch))
        (unload_dialog dch)
      )
      (if (= 'file (type des))
        (close des)
      )
      (if (and (= 'str (type dcl)) (setq dcl (findfile dcl)))
        (vl-file-delete dcl)
      )
      (if (and msg (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*")))
        (princ (strcat "\nError: " msg))
      )
      (princ)
    )
    (if
      (and
        (setq dcl (vl-filename-mktemp "tmp.dcl"))
        (setq des (open dcl "w"))
        (write-line
          (strcat
            "listbox : list_box { }
          example : dialog { label = \"Dump Object\"; spacer; : row {
          : listbox { key = \"ls1\"; label =  \"Properties\"; width = 50; height = 20; fixed_width = false; fixed_height = false; multiple_select = false ; }
          : column {}
          : listbox { key = \"ls2\"; label =  \"Methods\"; width = 30; height = 20; fixed_width = false; fixed_height = false; multiple_select = false ; }}
          ok_only;}"
          )
          des
        )
        (not (setq des (close des)))
        (< 0 (setq dch (load_dialog dcl)))
        (new_dialog "example" dch)
      )
       (progn (if lis1
                (progn (start_list "ls1")
                       (foreach itm lis1
                         (add_list (strcat (vl-princ-to-string (car itm)) " = " (vl-princ-to-string (cadr itm))))
                       )
                       (end_list)
                )
              )
              (if lis2
                (progn (start_list "ls2") (foreach itm lis2 (add_list itm)) (end_list))
              )
              (start_dialog)
       )
    )
    (if (< 0 dch)
      (unload_dialog dch)
    )
    (if (setq dcl (findfile dcl))
      (vl-file-delete dcl)
    )
    (princ)
  )
  ;;
  ;| -------------------------------------------------------------------------
------------------------------------------------------------------------------
         ACTUAL PROGRAM STARTED       
------------------------------------------------------------------------------
------------------------------------------------------------------------------
  |;
  (setq prop&methods (vlax-dump-object->list (vlax-ename->vla-object (car (entsel))) T))
  (LM:ListBox2 (car prop&methods) (cadr prop&methods))
  (princ)
)

Run by typing LM_DumpObject in command prompt.

T.Willey

  • Needs a day job
  • Posts: 5170
Re: vlax-dump-object->List
« Reply #26 on: January 10, 2017, 09:19:35 am »
By the way Andrea, I had a similar idea. However I'm a "hobby programmer" so wrote only this (BrowseThruDictionaries - starting from the namedobjdict):
<snip>
You may be interested in this post then, as it is an entity walker program (not a full as MP's though): https://www.theswamp.org/index.php?topic=51751.0
Once the code is loaded, you can look through the NamedObjDict like
(ChaseEntData (NamedObjDict))

Tim is an awesome programmer and artist.
Thanks MP (for the compliment and all the help along the way).
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.