(defun c:test( / ACADDOC ANG LEFTDOWNPOINT OFFSETLEFTDOWNPOINT USEROS SELECTIONSET) ;加载vlisp函数 (vl-load-com) ;当前文档 (setq acaddoc (vla-get-activedocument (vlax-get-acad-object))) ;选择处理对象 (if (ssget '((0 . "TEXT"))) (progn ;当前选集 (setq selectionset (vla-get-activeselectionset acaddoc)) ;保存捕捉 (setq useros (getvar "OSMODE")) ;遍历选集处理对象 (vlax-for obj selectionset ;文字对象外框 (vla-getboundingbox obj 'leftdownpoint 'rightuppoint) ;设置颠倒:否 (vla-put-upsidedown obj :vlax-false) ;设置反向:否 (vla-put-backward obj :vlax-false) ;文字角度 (setq ang (vla-get-rotation obj)) ;调整角度 (if (and (> ang (* pi 0.5)) (<= ang (* pi 1.5))) (vla-put-rotation obj (+ ang pi)) ) ;修改后的文字外框 (vla-getboundingbox obj 'offsetleftdownpoint 'offsetrightuppoint) ;文字归位 (vla-move obj offsetleftdownpoint leftdownpoint) ) ;恢复捕捉 (setvar "OSMODE" useros) ) ) ;静默退出 (princ) ) |