Jump to content

XREF PATH - COPY TO CLIPBOARD


Recommended Posts

Posted

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

Posted (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 by mhupp
  • Like 2
Posted

Hi mhupp,

 

Thank you for the response.

the result says: ; error: ActiveX Server returned the error: unknown name: IsXRef

  • Agree 1
Posted (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 by mhupp
Posted

Great! it worked, thank you so much!

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...