james9710 Posted 23 hours ago Posted 23 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 10 hours ago Posted 10 hours ago (edited) Untested I remember Lee Mac saying it was important to release the html 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 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 1 hour ago by mhupp 2 Quote
james9710 Posted 2 hours ago Author Posted 2 hours ago Hi mhupp, Thank you for the response. the result says: ; error: ActiveX Server returned the error: unknown name: IsXRef Quote
mhupp Posted 1 hour ago Posted 1 hour ago oops need to get the effective name against the block table. updated code. 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.