Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

copy file path to clipboard

17 REPLIES 17
Reply
Message 1 of 18
Anonymous
2565 Views, 17 Replies

copy file path to clipboard

is there a lisp or tool out there that can copy the file path to clipboard?
17 REPLIES 17
Message 2 of 18
Anonymous
in reply to: Anonymous

You will have to make a string.. of the file path.. add it as
Text to the drawing..use (command "_copyclip" .. to add
the 'Last' entity to the ClipBoard. Like this:
(setq path (getvar "dwgprefix"))
(command "_text" "C" "0,0" "2.0" path); or similar depending
on font..
(command "_copyclip" "L" "")
(command "_erase" "L" "")

Bob
Message 3 of 18
Anonymous
in reply to: Anonymous

I thought that would work also but didn't. Went to notepad and tried pasting
and nothing was there.

--
Message 4 of 18
Anonymous
in reply to: Anonymous

Because it is copying an object not the string.

For example, double-click on the text - highlight it - right-click - copy
=== then paste it into a text file.



//***
"Jason Rhymes" wrote in message
news:5962018@discussion.autodesk.com...
I thought that would work also but didn't. Went to notepad and tried pasting
and nothing was there.

--
Message 5 of 18
Anonymous
in reply to: Anonymous

Why doesn't this work?

(defun filepre (/ tmpf f)
(setq tmpf (vl-filename-mktemp nil nil ".tmp")
f (open tmpf "w")
)
(write-line (getvar "dwgprefix") f)
(vl-file-copy f "")
;;(read-line f)
(close f)
)
Message 6 of 18
Anonymous
in reply to: Anonymous

I think I understand what you are trying to do.... but all will be a waste
of time, it is much easier if you do:

Command: (getvar "dwgprefix") hit enter and grab the text from there

Or

Use the dos-lib clipboard function as part of one lisp routine.



//***
"Jason Rhymes" wrote in message
news:5962063@discussion.autodesk.com...
Why doesn't this work?

(defun filepre (/ tmpf f)
(setq tmpf (vl-filename-mktemp nil nil ".tmp")
f (open tmpf "w")
)
(write-line (getvar "dwgprefix") f)
(vl-file-copy f "")
;;(read-line f)
(close f)
)
Message 7 of 18
Anonymous
in reply to: Anonymous

Also, here is a link to a previous answer, here.

http://discussion.autodesk.com/thread.jspa?threadID=667608
Message 8 of 18
Anonymous
in reply to: Anonymous

I was assuming you wanted it for AutoCAD .dwg / paste.
Won't get it done for Windows Clipboard.

Bob
Message 9 of 18
Anonymous
in reply to: Anonymous

Microsoft has a free cmd line utlity "clip.exe" which you can use to pipe or redirect text (or text files) to the Windows Clipboard.

Perhaps you can use clip.exe in conjunction with some lisp to get your desired result.
Message 10 of 18
Anonymous
in reply to: Anonymous

;;copy file path/name to the clipboard
;;requires DOSLIB www.mcneel.com
(defun c:copyfilepath (/ fn)
(dos_clipboard
(setq fn (strcat (getvar "dwgprefix") (getvar "dwgname")))
)
(princ (strcat fn " copied to clipboard."))
(princ)
)



-Josh
Message 11 of 18
Anonymous
in reply to: Anonymous

Hi Kevin
How to use this stuff?

Thanks in advance

~'J'~
Message 12 of 18
barry2104
in reply to: Anonymous

I want to have a Lisp to not only copy the filepath of the current .dwg to the clipboard, but also Display the filepath in the command bar (e.g. to check that the current drawing is in the Folder it should be).

Can someone out there amend the Lisp for me?

Running AutoCAD Architecture 2020, in German
Message 13 of 18
ВeekeeCZ
in reply to: barry2104

Not sure which routine you're referring to, if any.

 

This should work.

(vl-load-com)

(defun c:Path2ClipBoard ( / en tx html) 

  (princ "\nFilepath to clipboard: ")
  (and (princ (setq tx  (getvar "dwgprefix")))
       (vlax-invoke (vlax-get (vlax-get (setq html (vlax-create-object "htmlfile")) 'ParentWindow) 'ClipBoardData) 'setData "Text" tx)
       (vlax-release-object html)
       )
  (princ)
)
Message 14 of 18
barry2104
in reply to: ВeekeeCZ

thanks, that works nearly perfectly.

I just also Need the filename after the folderpath. Currently the above code only Displays/copies as far as the Folder the current drawing is in, but not the .dwg Name itself

After executing the Lisp command, I want to be able to just press CTRL+V in an Email to paste the entire Filepath in, so that a colleague just clicks the link and the .dwg opens

I assume it's as simple as adding a "nfilename" into the code somewhere, but I'm not a coder and don't know where...

Running AutoCAD Architecture 2020, in German
Message 15 of 18
Anonymous
in reply to: Anonymous

I think you can right click the drawing tab for a quick menu that includes 'copy file path' (don't have autocad atm to check)

Message 16 of 18
barry2104
in reply to: Anonymous

Yes I’m aware you can do that too, but sometimes I just want to SEE the filepath in the command line to check it’s been saved where it should be. Hence the tweak to add filename after the filePATH/Folderpath.
Running AutoCAD Architecture 2020, in German
Message 17 of 18
ВeekeeCZ
in reply to: Anonymous


@Anonymous wrote:

I think you can right click the drawing tab for a quick menu that includes 'copy file path' (don't have autocad atm to check)


(vl-load-com)

(defun c:Path2ClipBoard ( / en tx html) 

  (princ "\nFilepath to clipboard: ")
  (and (princ (setq tx (strcat (getvar "dwgprefix") (getvar "dwgname"))))
       (vlax-invoke (vlax-get (vlax-get (setq html (vlax-create-object "htmlfile")) 'ParentWindow) 'ClipBoardData) 'setData "Text" tx)
       (vlax-release-object html)
       )
  (princ)
)
Message 18 of 18
Anonymous
in reply to: barry2104

oh sorry, I was replying to the first post, didn't notice it was from 10 years ago  😛

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost