18
59
41
初露锋芒
使用道具 举报
5
1334
1410
限制会员
(defun c:d? ( / *error* DTR GetMTextBB ogt ch d mt pts p1 p2 p3 p4 pl ) (defun *error* ( msg ) (if ogt (setvar 'offsetgaptype ogt)) (if msg (prompt msg)) (princ) ) (defun DTR ( a ) (* (/ a 180.0) pi) ) (defun GetMTextBB ( Ent / EntData EnsPt TxtJust TxtWd TxtHt TxtRot LeftX RightX TopY BottomY ) ;;; Source : https://groups.google.com/forum/#!topic/autodesk.autocad.customization/gGZBLTD3Qls ;;; Get real Bounding Box for MText ;;; Tim Willey 03/2005 ;;; Improved for any angle Text by mailmaverick 12-12-2013 ;;; Thanks to OLD-CADaver for the tips on the DXF codes ;;; Points p1, p2, p3 and p4 are explained below : ;;; If the MTEXT gets rotated, the points remain the same. ;| ; p3 p2 ------------------------ | | | | | | | | | | | | ------------------------ p1 p4 ; |; (setq EntData (entget Ent)) (setq InsPt (acet-dxf 10 EntData)) (setq TxtJust (acet-dxf 71 EntData)) (setq TxtRot (acet-dxf 50 EntData)) (setq TxtWd (acet-dxf 42 EntData)) (setq TxtHt (acet-dxf 43 EntData)) (cond ((= TxtJust 1) (setq p3 InsPt) (setq p1 (polar p3 (+ (DTR 270) TxtRot) TxtHt)) (setq p2 (polar p3 TxtRot TxtWd)) (setq p4 (polar p1 TxtRot TxtWd)) ) ((= TxtJust 2) (setq p3 (polar Inspt (+ (DTR 180) TxtRot) (/ TxtWd 2))) (setq p1 (polar p3 (+ (DTR 270) TxtRot) TxtHt)) (setq p2 (polar p3 TxtRot TxtWd)) (setq p4 (polar p1 TxtRot TxtWd)) ) ((= TxtJust 3) (setq p2 Inspt) (setq p3 (polar p2 (+ (DTR 180) TxtRot) TxtWd)) (setq p1 (polar p3 (+ (DTR 270) TxtRot) TxtHt)) (setq p4 (polar p1 TxtRot TxtWd)) ) ((= TxtJust 4) (setq p3 (polar Inspt (+ (DTR 90) TxtRot) (/ TxtHt 2))) (setq p1 (polar p3 (+ (DTR 270) TxtRot) TxtHt)) (setq p2 (polar p3 TxtRot TxtWd)) (setq p4 (polar p1 TxtRot TxtWd)) ) ((= TxtJust 5) (setq temp (polar Inspt (+ (DTR 90) TxtRot) (/ TxtHt 2))) (setq p3 (polar temp (+ (DTR 180) TxtRot) (/ TxtWd 2))) (setq p1 (polar p3 (+ (DTR 270) TxtRot) TxtHt)) (setq p2 (polar p3 TxtRot TxtWd)) (setq p4 (polar p1 TxtRot TxtWd)) ) ((= TxtJust 6) (setq p2 (polar Inspt (+ (DTR 90) TxtRot) (/ TxtHt 2))) (setq p3 (polar p2 (+ (DTR 180) TxtRot) TxtWd)) (setq p1 (polar p3 (+ (DTR 270) TxtRot) TxtHt)) (setq p4 (polar p1 TxtRot TxtWd)) ) ((= TxtJust 7) (setq p1 Inspt) (setq p3 (polar p1 (+ (DTR 90) TxtRot) TxtHt)) (setq p2 (polar p3 TxtRot TxtWd)) (setq p4 (polar p1 TxtRot TxtWd)) ) ((= TxtJust (setq p1 (polar Inspt (+ (DTR 180) TxtRot) (/ TxtWd 2))) (setq p3 (polar p1 (+ (DTR 90) TxtRot) TxtHt)) (setq p2 (polar p3 TxtRot TxtWd)) (setq p4 (polar p1 TxtRot TxtWd)) ) ((= TxtJust 9) (setq p4 Inspt) (setq p2 (polar p4 (+ (DTR 90) TxtRot) TxtHt)) (setq p3 (polar p2 (+ (DTR 180) TxtRot) TxtWd)) (setq p1 (polar p3 (+ (DTR 270) TxtRot) TxtHt)) ) ) (list p1 p2 p3 p4) ) (setq ogt (getvar 'offsetgaptype)) (setvar 'offsetgaptype 0) (if (not (tblsearch "LAYER" "dim_revcloud")) (entmake '((0 . "LAYER") (100 . "AcDbSymbolTableRecord") (100 . "AcDbLayerTableRecord") (2 . "dim_revcloud") (70 . 0) (62 . 6) (6 . "Continuous"))) (prompt "\nLayer : "dim_revcloud" already exist - setting it to current and proceeding with routine...") ) (setvar 'clayer "dim_revcloud") (initget "1 2") (setq ch (getkword "\nChoose text of dimension [1.? D.E. / 2.? E.O.S.] <?>: ")) (cond ( (eq ch nil) (prompt "\nPick start and end point of linear dimension...") (command "_.dimaligned" "\" "\" "t" "?") (while (> (getvar 'cmdactive) 0) (command "\")) ) ( (eq ch "1") (prompt "\nPick start and end point of linear dimension...")