马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
MTEXT的一个处理代码,使用了正则表达式替换
 - (defun c:stackchange ( / inc obj rgx sel str )
- (if (setq sel (ssget "_:L" '((0 . "MTEXT") (-4 . "<OR") (1 . "*#/#*") (3 . "*#/#*") (-4 . "OR>"))))
- (if (setq rgx (vlax-create-object "vbscript.regexp"))
- (progn
- (vlax-put-property rgx 'global actrue)
- (vlax-put-property rgx 'ignorecase actrue)
- (vlax-put-property rgx 'multiline actrue)
- (vlax-put-property rgx 'pattern "(?:(\\d)[ \\-])?(?:\\{\\\\H[^;]+;\\\\S)*(\\d+)/(\\d+)(?:;\\})*")
- (repeat (setq inc (sslength sel))
- (setq obj (vlax-ename->vla-object (ssname sel (setq inc (1- inc))))
- str (vla-get-textstring obj)
- )
- (vla-put-textstring obj (vlax-invoke rgx 'replace str "$1{\\H0.7x;\\S$2#$3;}"))
- )
- (vlax-release-object rgx)
- )
- (princ "\nUnable to interface with RegExp object.")
- )
- )
- (princ)
- )
|