- (if (null vlax-dump-object) (vl-load-com));;将 Visual LISP 扩展功能加载到 AutoLISP
- ;提取多行文字,去除无用格式符号--(一级)----
- ;由尘缘一生提供 QQ:15290049
- (defun gets-mt (nam / s ob)
- (setq s (vlax-get (vlax-ename->vla-object nam) 'TextString))
- (vlax-put-property (setq ob (vlax-create-object "Vbscript.RegExp")) "IgnoreCase" 0)
- (vlax-put-property ob "Global" 1)
- (setq s
- (mapcar
- '(lambda (x y) (vlax-put-property ob "Pattern" x) (setq s (vlax-invoke-method ob "Replace" s y)))
- '("\\\\\\\\" "\\\\{" "\\\\}" "\\\\p(.[^;]*);" "\\\\S(.[^;]*)(\\^|#|\\\\)(.[^;]*);"
- "(\\\\F|\\\\f|\\\\C|\\\\H|\\\\T|\\\\Q|\\\\W|\\\\A)(.[^;]*);" "(\\\\L|\\\\O|\\\\l|\\\\o)" "\\\\~"
- "\\\\P" "\n" "({|})" "\\x01" "\\x02" "\\x03")
- (list (chr 1) (chr 2) (chr 3) "" "" "" "" "" (chr 0) "" "" "\\" "{" "}")
- )
- )
- (if ob (vlax-release-object ob))
- (last s)
- )
- ;样例
- (defun c:tt (/ str)
- (setq mtext_name (car(entsel "\n 请选择MTEXT文字:?")))
- (setq str (gets-mt mtext_name))
- str
- )
|