3dwannab Posted November 26, 2024 Posted November 26, 2024 (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 November 26, 2024 by 3dwannab Quote
mhupp Posted November 27, 2024 Posted November 27, 2024 probably be easier to dump to a text file. Quote
Saxlle Posted November 27, 2024 Posted November 27, 2024 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. Quote
3dwannab Posted November 27, 2024 Author Posted November 27, 2024 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. Quote
Recommended Posts
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.