替换多行文字中的文字有两种基本方法。假设您将要存储的文本存储在lisp变量STR中,并将多行文字选定,其名称存储在lisp变量en中:
1、通过entmod。
- (setq ed (entget en)) ;Get the DXF data list
- (setq ed (subst (cons 1 str) (assoc 1 ed) ed)) ;Modify the DXF list
- (entmod ed) ;Modify the entity
1a。这可能会导致注释性缩放文本出现问题。出于这个原因,我宁愿这样说:
- (entmod (list (cons -1 en) (cons 1 str)))
2。vla方法(也不会给出注释性问题)
要附加到它,您需要首先获得现有值:
1.再次注意注释性缩放
- (setq ed (entget en)) ;Get the DXF data list
- (setq ed (subst (cons 1 (strcat (cdr (assoc 1 ed)) str)) (assoc 1 ed) ed)) ;Modify the DXF list
- (entmod ed) ;Modify the entity
1a。这变得有点强迫了
- (setq ed (entget en)) ;Get the DXF data list
- (entmod (list (cons -1 en) (cons 1 (strcat (cdr (assoc 1 ed)) str))))
2。IMO最简单的方法
- (setq eo (vlax-ename->vla-object en)) ;Get the ActiveX object of the entity
- (vla-put-TextString eo (strcat (vla-get-TextString eo) str)) ;Change the text inside the MText
|