james9710 Posted December 10, 2025 Posted December 10, 2025 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 December 10, 2025 Posted December 10, 2025 (edited) Untested I remember Lee Mac saying it was important to release the html obj as it could cause a memory leak or something. ;;----------------------------------------------------------------------------;; ;; 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 html) (vl-load-com) (if (setq SS (ssget "_+.:E:S" '((0 . "INSERT")))) (progn (setq blk (vla-get-effectivename (vlax-ename->vla-object (ssname SS 0)))) (setq blk (vla-item (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) blk)) (if (= (vla-get-isxref blk) :vlax-true) (progn (setq Path (vla-get-Path blk)) (vlax-invoke (vlax-get (vlax-get (setq html (vlax-create-object "htmlfile")) 'ParentWindow) 'ClipBoardData) 'setData "Text" Path) (vlax-release-object html) (alert (strcat "\nPath Sent to Clipboard\n Xref Path: " Path)) ) (princ "\nSelected Block isn't an Xref.") ) ) (princ "\nNothing Selected") ) (princ) ) -edit updated code. Edited December 11, 2025 by mhupp 2 Quote
james9710 Posted December 11, 2025 Author Posted December 11, 2025 Hi mhupp, Thank you for the response. the result says: ; error: ActiveX Server returned the error: unknown name: IsXRef 1 Quote
mhupp Posted December 11, 2025 Posted December 11, 2025 (edited) Need to pull the effective block name and check it against the block table. That is where the path is stored. updated code. Edited December 11, 2025 by mhupp Quote
james9710 Posted December 12, 2025 Author Posted December 12, 2025 Great! it worked, thank you so much! 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.