[讨论] 仿JUSTIFYTEXT
;; [功能] 获取两点的中点坐标(defun MJ:MIDPOINT (P1 P2)
(mapcar '(lambda (X Y) (* (+ X Y) 0.5)) P1 P2)
)
(defun C:t1 (/ KEY SS)
(setq ss (ssget '((0 . "TEXT"))))
(initget "L A F C M R TL TC TR ML MC MR BL BC BR ")
(setq key
(getkword
"\n[左对齐(L)/对齐(A)/布满(F)/居中(C)/中间(M)/右对齐(R)/左上(TL)/中上(TC)/右上(TR)/左中(ML)/正中(MC)/右中(MR)/左下(BL)/中下(BC)/右下(BR)] <正中(MC)>:"
)
)
(if (not key)
(setq key "MC")
)
(MY-JUSTIFYTEXT ss key)
(princ)
)
(DEFUN MY-JUSTIFYTEXT(ss key / E EN N P P10 PTS)
(repeat (setq n (sslength ss))
(setq e (ssname ss (setq n (1- n))))
(setq en (entget e))
(setq p10(cdr (assoc 10 en)))
(setq pts (textbox en))
(setq p (apply 'MJ:MIDPOINT pts))
(cond
((= key "L");左对齐
(entmod (append en
(list (cons 10 p10)
'(71 . 0)
'(72 . 0)
'(11 0 0)
'(73 . 0)
)
)
)
)
((= key "A");/对齐
(entmod (append en
(list (cons 10 p10)
'(71 . 0)
'(72 . 3)
(list 11 (+ (car p10) (caadr pts)) (cadr p10))
'(73 . 0)
)
)
)
)
((= key "F");/布满
(entmod (append en
(list (cons 10 p10)
'(71 . 0)
'(72 . 5)
(list 11 (+ (car p10) (caadr pts)) (cadr p10))
'(73 . 0)
)
)
)
)
((= key "C");居中
(entmod (append en
(list (cons 10 p10)
'(71 . 0)
'(72 . 1)
(list 11 (+ (car p10) (car p)) (cadr p10))
'(73 . 0)
)
)
)
)
((= key "M");/中间
(entmod (append en
(list (cons 10 p10)
'(71 . 0)
'(72 . 4)
(cons 11 (mapcar '+ p p10))
'(73 . 0)
)
)
)
)
((= key "R");右对齐(R)
(entmod (append en
(list (cons 10 p10)
'(71 . 0)
'(72 . 2)
(list 11 (+ (car p10) (caadr pts)) (cadr p10))
'(73 . 0)
)
)
)
)
((= key "TL");/左上
(entmod (append en
(list (cons 10 p10)
'(71 . 0)
'(72 . 0)
(list 11 (car p10) (+ (cadr p10) (cadadr pts)))
'(73 . 3)
)
)
)
)
((= key "TC");/中上
(entmod (append en
(list (cons 10 p10)
'(71 . 0)
'(72 . 1)
(list 11 (+ (car p10) (car p)) (+ (cadr p10) (cadadr pts)))
'(73 . 3)
)
)
)
)
((= key "TR");/右上
(entmod (append en
(list (cons 10 p10)
'(71 . 0)
'(72 . 2)
(list 11 (+ (car p10) (caadr pts)) (+ (cadr p10) (cadadr pts)))
'(73 . 3)
)
)
)
)
((= key "ML");/左中
(entmod (append en
(list (cons 10 p10)
'(71 . 0)
'(72 . 0)
(list 11 (car p10) (+ (cadr p10) (cadr p)))
'(73 . 2)
)
)
)
)
((= key "MC");/正中
(entmod (append en
(list (cons 10 p10)
'(71 . 0)
'(72 . 1)
(cons 11 (mapcar '+ p10 p))
'(73 . 2)
)
)
)
)
((= key "MR");/右中
(entmod (append en
(list (cons 10 p10)
'(71 . 0)
'(72 . 2)
(list 11 (+ (car p10) (caadr pts)) (+ (cadr p10) (cadr p)))
'(73 . 2)
)
)
)
)
((= key "BL");/左下
(entmod (append en
(list (cons 10 p10)
'(71 . 0)
'(72 . 0)
(cons 11 p10)
'(73 . 1)
)
)
)
)
((= key "BC");/中下
(entmod (append en
(list (cons 10 p10)
'(71 . 0)
'(72 . 1)
(list 11 (+ (car p10) (car p)) (cadr p10))
'(73 . 1)
)
)
)
)
((= key "BR");右下
(entmod (append en
(list (cons 10 p10)
'(71 . 0)
'(72 . 2)
(list 11 (+ (car p10) (caadr pts)) (cadr p10))
'(73 . 1)
)
)
)
)
)
)
)
页:
[1]