Andyhon 发表于 2011-12-5 17:39
(defun c:c1 ()
(vl-load-com)
(princ "\n字串一: ") - ;;程序中的字符串哪里来的?我有个从cad中复制到剪切板的。
- ;;;=================================================================*
- ;;;功能:向系统剪贴板写入文字 *
- (defun ZML-CLIP-SETSTRING (STR / HTML RESULT)
- (and (= (type STR) 'STR)
- (setq HTML (vlax-create-object "htmlfile"))
- (setq RESULT (vlax-invoke
- (vlax-get (vlax-get HTML 'PARENTWINDOW)
- 'CLIPBOARDDATA
- )
- 'SETDATA
- "Text"
- STR
- )
- )
- (vlax-release-object HTML)
- )
- )
- ;;;=================================================================*
- ;;函数测试
- (defun c:c3 ()
- (vl-load-com)
- (setq ss (ssget '((0 . "*TEXT"))))
- (setq i 0)
- (setq last_stri_str "")
- (repeat (sslength ss)
- (setq txtcon (cdr (assoc 1 (entget (ssname ss i)))))
- (setq txtcon_kuohao (strcat "(" txtcon ")"))
- (setq last_stri (vl-prin1-to-string txtcon_kuohao))
- (setq last_stri_str (strcat last_stri_str last_stri))
- (setq i (1+ i))
- )
- (setq str0 (getvar "DwgName") ;"宗地图.dwg"
- str0 (substr str0 1 )
- ) ;"宗地图"
- (setq str1 (vl-string-translate "/" "-" last_stri_str))
- (setq str2 (vl-string-translate """ " " str1))
-
- (while (> (strlen str2) (strlen (setq str2 (vl-string-subst "" " " str2))))) ;;加了这句就可以了。
- (setq str0 (vl-string-subst "" ".dwg" str0)) 。
- (setq str3 (strcat str0 str2))
- (ZML-CLIP-SETSTRING str3)
- (princ "\n文字已复制到剪切板,可以直接粘贴了!")
- (princ)
- )
- ;;(while (> (strlen str) (strlen (setq str (vl-string-subst "" " " str)))))
|