Author Topic: Copy values to clipboard  (Read 1523 times)

0 Members and 1 Guest are viewing this topic.

milanp

  • Newt
  • Posts: 35
Copy values to clipboard
« on: February 21, 2020, 03:45:52 PM »
Do you know how to add func to copy values (X,Y coordinates) to clipboard? Code works well, but I always need to manually copy values. Thanks!

Code: [Select]

(defun C:tacka ( / pt)
(setq pt (getpoint "\nKlikni na zeljeno mesto: "))
(if pt
 (prompt (strcat "\n" (rtos (car (trans pt 1 0)) 2)
                      "," (rtos (cadr (trans pt 1 0)) 2)))
 )
(princ)
)



EDIT (John): Removed question mark at end of code block.
« Last Edit: February 25, 2020, 02:19:23 PM by milanp »

BIGAL

  • Swamp Rat
  • Posts: 1419
  • 40 + years of using Autocad
Re: Copy values to clipboard
« Reply #1 on: February 21, 2020, 10:37:33 PM »
Copyclip that simple. Opposite copypaste. Can be variable or objects etc.
A man who never made a mistake never made anything

Tutulisper

  • Mosquito
  • Posts: 11
Re: Copy values to clipboard
« Reply #2 on: February 24, 2020, 06:22:52 AM »
Code - Auto/Visual Lisp: [Select]
  1. (defun SETCLIPTEXT (STR / HTML RESULT)
  2.         (VL-load-com)
  3.         (and (= (type STR) 'STR)
  4.              (setq HTML (vlax-create-object "htmlfile"))
  5.              (setq RESULT (vlax-invoke
  6.                             (vlax-get (vlax-get HTML 'PARENTWINDOW)
  7.                                       'CLIPBOARDDATA
  8.                             )
  9.                             'SETDATA
  10.                             "Text"
  11.                             STR
  12.                           )
  13.              )
  14.              (vlax-release-object HTML)
  15.         )
  16. )
this code can do it


EDIT (John): Added code tags.
« Last Edit: February 24, 2020, 09:37:06 AM by John Kaul (Se7en) »

snownut2

  • Swamp Rat
  • Posts: 971
  • Bricscad 22 Ultimate
Re: Copy values to clipboard
« Reply #3 on: February 24, 2020, 07:34:32 AM »
Here's the clipboard functions I use....

Code - Auto/Visual Lisp: [Select]
  1.     (defun ClearClipBoard ( )
  2.       (startapp "cmd /c \"echo off | clip\"" )
  3.     ); (clearclipboard)
  4.  
  5.     (defun _SetClipBoardText ( text / htmlfile result )
  6.     ;;  Caller's sole responsibility is to pass a
  7.     ;;  text string. Anything else? Pie in face.
  8.  
  9.     ;;  Attribution: Reformatted version of
  10.     ;;  post by XShrimp at theswamp.org.
  11.     ;;
  12.     ;;  See http://tinyurl.com/2ngf4r.
  13.  
  14.       (setq result
  15.         (vlax-invoke
  16.           (vlax-get
  17.             (vlax-get
  18.               (setq htmlfile (vlax-create-object "htmlfile"))
  19.               'ParentWindow
  20.             )
  21.             'ClipBoardData
  22.           )
  23.           'SetData
  24.           "Text"
  25.           text
  26.         )
  27.       )
  28.       (vlax-release-object htmlfile)
  29.       text
  30.     );( _SetClipBoardText "testing")
  31.  
  32.   (defun _GetClipBoardText( / htmlfile result )
  33.     ;;  Attribution: Reformatted version of
  34.     ;;  post by Patrick_35 at theswamp.org.
  35.     ;;
  36.     ;;  See http://tinyurl.com/2ngf4r.
  37.     (setq result
  38.             (vlax-invoke
  39.               (vlax-get
  40.                 (vlax-get
  41.                         (setq htmlfile (vlax-create-object "htmlfile"))
  42.                         'ParentWindow
  43.                       )
  44.                 'ClipBoardData
  45.         )
  46.               'GetData
  47.               "Text"
  48.       )
  49.           )
  50.     (vlax-release-object htmlfile)
  51.     result
  52.   );(setq test (_GetClipBoardText))
  53.  
  54.  

milanp

  • Newt
  • Posts: 35
Re: Copy values to clipboard
« Reply #4 on: February 25, 2020, 04:26:30 PM »
Thanks folks.

 :idea: