;粘贴板clipboard.lsp
;; !                           setToclipboard
;; ! ***************************************************************************
;; ! Function : set text to clipboard
;; ! Argument : 'str'     - String
;; ! Returns  : nil
;; ! ****************************************************************************|;

(defun mai_setClipText ( str / html )
  (if (= 'STR (type str))
      (progn
         (setq html   (vlax-create-object "htmlfile"))
         (vlax-invoke (vlax-get (vlax-get html 'ParentWindow) 'ClipBoardData) 'setData "Text" str)
         (vlax-release-object html)
         T
      )
  );end if
)

;; !                           Clearclipboard
;; ! ***************************************************************************
;; ! Function : Clear clipboard
;; ! Argument : nil
;; ! Returns  : nil
;; ! ****************************************************************************|;
(defun mai_Clearclipboard (  / html )
    (setq html   (vlax-create-object "htmlfile"))
    (vlax-invoke (vlax-get (vlax-get html 'ParentWindow) 'ClipBoardData) 'clearData "Text")
    (vlax-release-object html)
    (princ)
)

;; !                           Getclipboard
;; ! ***************************************************************************
;; ! Function : Return text string from clipboard
;; ! Argument : nil
;; ! Returns  : string
;; ! ****************************************************************************|;

(defun mai_Getclipboard ( / html str)
    (setq html   (vlax-create-object "htmlfile"))
    (setq str (vlax-invoke (vlax-get (vlax-get html 'ParentWindow) 'ClipBoardData) 'getData "Text"))
    (vlax-release-object html)
     str
)


;;;;;输出文字到粘贴板的
(defun c:mini_text_2_clipboard ( / old_cmd ss tt )
  (mai_start nil)
  (setq ss (mai_select_first '((0 . "TEXT")) "选择需要输出到粘贴板的文字 Text:" "没有选择文字实体.")
        tt (mai_lst2str 
             (mapcar
                '(lambda(x) (apply 'strcat (mapcar '(lambda(y) (mai_dxf 1 y)) x)))
                 (mai_order_text ss)
             )
             "\n"
           )
  )
  (mai_setClipText tt)
  (princ (strcat "\n共<" (itoa (sslength ss)) ">个文字实体被输出到粘贴板."))
  (mai_end)
)

