本帖最后由 wmz 于 2020-10-11 15:09 编辑
- ;;;;;;;将多行文字转换为单行文字
- (defun c:MtoTa(/ f e e0 ee m str p0 pp h H0 KD n n1 nn str0 str1 stra)
- (vl-load-com)
- ; (setq f (open "C:/10.txt" "w"))
- (setq e (ssget "X" '((0 . "MTEXT"))))
- (if e (progn
- (setq m 0 n nil nn 0 str0 "" str1 "" stra "")
- (repeat (sslength e)
- (setq e0 (ssname e m) m (1+ m))
- (setq ee (entget e0))
- (setq str (cdr(assoc 1 ee)))
- (setq p0 (cdr(assoc 10 ee)))
- (setq H (cdr(assoc 40 ee)))
- (setq H0 (cdr(assoc 43 ee)))
- (setq KD (cdr(assoc 42 ee)))
- (setq pp (list (+(car p0)(/ KD 2.0))(-(cadr p0)(/ H0 2.0))))
- (while
- (setq n (vl-string-search ";" str))
- (setq str (substr str (+ n 2)))
- )
- (setq str (vl-string-subst "" "}" str))
- (setq nn (strlen str) n1 1 stra "")
- (repeat nn
- (setq str1 "" str0 "")
- (setq str0 (substr str n1 1) n1 (1+ n1))
- (if (and(> n1 2)(<= n1 nn))(setq str1 (substr str (- n1 2) 1)))
- (cond ((and(= str0 "P")(/= str1 "\"))(setq stra (strcat stra str0)))
- ((and(/= str0 "\")(/= str0 "P"))(setq stra (strcat stra str0)))
- )
- );;;;;;end nn
- (command "erase" e0 "")
- (command "TEXT" "M" pp h "360" stra)
- ;(write-line stra f)
- (print "stra=")(princ stra)(princ)
- )
- ));;;;;end (if e
- ;(close f)
- )
|