Jump to content

Recommended Posts

Posted (edited)

Hi all,

 

Is there a way to dump the properties and methods of an object to the clipboard?

 

I thought this would work below (It only returns T)

; Dumps the VLA object's properties and methods to the clipboard.
(defun c:dumpobj (/ dump-text html obj) 
  (if (setq obj (vlax-ename->vla-object (car (entsel "\nSelect an object: ")))) 
    (progn 
      ; (vlax-dump-object obj T) ; Display in the console for reference
      (setq dump-text (vl-prin1-to-string (vlax-dump-object obj T))) ; Get as string
      ;; Set the combined text to the clipboard
      (vlax-invoke 
        (vlax-get (vlax-get (setq html (vlax-create-object "htmlfile")) 'ParentWindow) 'ClipBoardData)
        'setData
        "Text"
        dump-text
      )
      (vlax-release-object html)
      (princ "\nDump copied to the clipboard.")
    )
    (princ)
  )
)

 

Edited by 3dwannab
Posted

probably be easier to dump to a text file.

Posted

Maybe the "COPYHIST" command (it copies everything from command line history to the Clipboard) can help with this, but you need to copy everything into Notepad or a similar editor, then delete everything before and after to get a list of all properties and methods. It's not practical, but it works.

Posted
19 hours ago, mhupp said:

probably be easier to dump to a text file.

Typically I have VSCode as my IDE so going Ctrl+N and pasting is my ideal.

 

I have modified the myentget function to copy to the clipboard. Apologies, I got this code before I took note of where it originated from.


 

(vl-load-com)

;; Get entity list of user picked entity plus related objects.
;; It also sets this info to the clipboard.

(defun c:myentget+ (/ ent elst html clipboardTxt slstTxt) 
  (if 
    (and (setq ent (car (entsel "\nSelect entity to list."))) 
         (setq elst (entget ent '("*")))
    )
    (progn 
      (textscr)
      (princ "\n>>>------>  ")
      (princ (vlax-ename->vla-object ent))
      (mapcar 'print elst)

      ;; Initialize slstTxt as empty
      (setq slstTxt "")

      ;; Process related objects (330 and 340 references)
      (mapcar 
        '(lambda (x / slst) 
           (if 
             (and (assoc x elst) 
                  (setq slst (entget (cdr (assoc x elst))))
             )
             (progn 
               (prompt (strcat "\n\n*******  Dump DXF " (itoa x) " listing  *********"))
               (foreach n slst (print n))

               ;; Append slst content to slstTxt for clipboard
               (setq slstTxt (strcat slstTxt 
                                     "\n******* DXF "
                                     (itoa x)
                                     " Listing *******\n"
                                     (apply 'strcat 
                                            (mapcar 
                                              '(lambda (s) (strcat (itoa (car s)) ": " (vl-princ-to-string (cdr s)) "\n"))
                                              slst
                                            )
                                     )
                             )
               )
             )
           )
         )
        '(330 340)
      )

      ;; Combine elst and slstTxt into clipboard text
      (setq clipboardTxt (strcat 
                           "******* Entity DXF Listing *******\n"
                           (apply 'strcat 
                                  (mapcar 
                                    '(lambda (s) (strcat (itoa (car s)) ": " (vl-princ-to-string (cdr s)) "\n"))
                                    elst
                                  )
                           )
                           "\n"
                           slstTxt
                         )
      )

      ;; Set the combined text to the clipboard
      (vlax-invoke 
        (vlax-get (vlax-get (setq html (vlax-create-object "htmlfile")) 'ParentWindow) 'ClipBoardData)
        'setData
        "Text"
        clipboardTxt
      )
      (vlax-release-object html)


      (if clipboardTxt (princ "\nThe objects data has been sent to the clipboard..."))
    )
  )
  (princ)
)

; (c:myentget+) ;; Unblock for testing

 

14 hours ago, Saxlle said:

COPYHIST

 

i never knew that command existed. Thanks. I'll try that.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...