嘘!
找到了上述代码的修改版本。
如果文本为多行文字,则此操作非常有效。
我不得不添加ERASE命令行,因为它已被引入
一个包围盒,然后把它留在那里。
你们所有的程序员可能都会嘲笑我的管道胶带修复,但它奏效了。。
它仍然将各个文本项都放在中心的顶部-\
如此接近。。。
- (defun c:ct2 (/ *error* vl ov i ss ent obj pt prop eLst poly)
- (vl-load-com)
- (defun *error* (msg)
- (and ov (mapcar 'setvar vl ov))
- (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
- (princ (strcat "\n** Error: " msg " **")))
- (princ))
- (setq vl '("CMDECHO" "OSMODE") ov (mapcar 'getvar vl))
- (mapcar 'setvar vl '(0 0))
- (if (setq i -1 ss (ssget "_:L" '((0 . "MTEXT,TEXT"))))
- (while (setq ent (ssname ss (setq i (1+ i))))
- (setq obj (vlax-ename->vla-object ent))
- (if (eq "AcDbText" (vla-get-ObjectName obj))
- (if (eq AcAlignmentLeft (vla-get-Alignment obj))
- (progn
- (setq tmp (vla-get-InsertionPoint obj))
- (vla-put-Alignment obj acAlignmentMiddleCenter)
- (vla-put-TextAlignmentPoint obj tmp))
- (vla-put-Alignment obj acAlignmentMiddleCenter))
- (vla-put-AttachmentPoint obj acAttachmentPointMiddleCenter))
- (setq pt (vlax-get obj
- (setq prop
- (if (eq "TEXT" (cdr (assoc 0 (entget ent))))
- 'TextAlignmentPoint 'InsertionPoint))))
- (setq eLst (entlast))
- (vl-cmdf "_.-boundary" pt "")
-
- (if (not (eq eLst (setq poly (entlast))))
- (progn
- (vla-getBoundingBox (vlax-ename->vla-object poly) 'MiP 'MaP)
- (setq pLst (mapcar 'vlax-safearray->list (list mIP maP)))
- (vlax-put-property obj prop
- (vlax-3D-point
- (polar (car pLst) (apply 'angle pLst) (/ (apply 'distance pLst) 2.))))
- (entdel poly))
- (princ "\n ** Boundary not Found ** "))))
- (mapcar 'setvar vl ov)
- (Command "Erase" "L" "")
- (princ))
|