james9710 Posted 15 hours ago Posted 15 hours ago hi, can anyone please assist creating a lisp to copy the "found at" path of selected xref to clipboard so i can paste the same to open the file in new autocad window. also I suggest to use command XPATH. the routine would be like: 1. command: XPATH 2. select an XREF 3. message: "found at path copied to clipboard". 4.(command end) Thanks a lot. James Quote
mhupp Posted 2 hours ago Posted 2 hours ago Untested I remember Lee Mac saying it was important to release the obj as it could cause a memory leak or something. the other commented out option will pop up the command prompt window for a split second and use the clip command. so if your cool with that its the better option as its only one line. ;;----------------------------------------------------------------------------;; ;; Copy Selected Xref Path to Clipboard with prompt. ;; https://www.cadtutor.net/forum/topic/98871-xref-path-copy-to-clipboard (defun c:XrefToClipBoard ( / SS Blk Path Obj Result) (vl-load-com) (if (setq SS (ssget "_+.:E:S" '((0 . "INSERT")))) (progn (setq Blk (vlax-ename->vla-object (ssname SS 0))) (setq Path "") (if (= (vla-get-isxref Blk) :vlax-true) (progn (setq Path (vla-get-path Blk)) ;(vlax-invoke (vlax-get-object "WScript.Shell") 'Run (strcat "cmd.exe /c echo " (vl-prin1-to-string Path) "| clip" ) 0 :vlax-true) ;This runs a command prompt (if (setq Obj (vlax-create-object "htmlfile")) (progn (setq Result (vlax-invoke (vlax-get (vlax-get Obj 'ParentWindow) 'ClipboardData) 'SetData "Text" Path)) (vlax-release-object Obj) ) ) (alert (strcat "\nCopied to Clipboard\n Xref Path: " Path)) ) (princ "\nSelected Block isn't an Xref.") ) ) (princ "\nNothing Selected") ) (princ) ) 2 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.