试试这个,完全没有经过测试:
- [color=Yellow];;; Match Text/Mtext Style and Height of source Text/Mtext object
- ;;; Alan J. Thompson, 11.03.09
- (defun c:MS (/ *error* #Obj #SS #Style #Size)
- ;;; error handler
- (defun *error* (#Message)
- (and *AcadDoc* (vla-endundomark *AcadDoc*))
- (and #Message
- (not (wcmatch (strcase #Message) "*BREAK*,*CANCEL*,*QUIT*"))
- (princ (strcat "\nError: " #Message))
- ) ;_ and
- ) ;_ defun
- (or *AcadDoc* (setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object))))
- (vla-startundomark *AcadDoc*)
- (cond
- ((and (setq #Obj (car (entsel "\nSelect source text object: ")))
- (vl-position (cdr (assoc 0 (entget #Obj))) '("MTEXT" "TEXT"))
- (setq #Obj (vlax-ename->vla-object #Obj))
- ;; (setq #Obj (AT:Entsel nil "\nSelect source text object: " '("V" (0 . "MTEXT,TEXT")) nil))
- (setq #SS (ssget "_:L" '((0 . "MTEXT,TEXT"))))
- ) ;_ and
- (setq #Style (vla-get-stylename #Obj)
- #Size (vla-get-height #Obj)
- ) ;_ setq
- (vlax-for x (setq #SS (vla-get-activeselectionset *AcadDoc*))
- (vl-catch-all-apply 'vla-put-stylename (list x #Style))
- (vl-catch-all-apply 'vla-put-height (list x #Size))
- ) ;_ vlax-for
- (vl-catch-all-apply 'vla-delete (list #SS))
- )
- ) ;_ cond
- (*error* nil)
- (princ)
- ) ;_ defun[/color]
此处更新了更强大的版本:http://www.cadtutor.net/forum/showthread.php?t=41669 |