|
发表于 2011-11-29 13:36:09
|
显示全部楼层
- (defun c:bdf (/ e ent tc newt mc ang st zb0 A& w: d5 P* A" D* y) h. ]
- zbx zby zg zb1x zb1y zb2x zb2y zb1 zb2* a! V& S5 f1 ^; K4 k- `
- oldosmode
" \3 \( U! A0 B$ T8 a - )5 L% i9 t, G: I ?+ {
- (setq oldosmode (getvar "osmode")) ;记录用户当前的对象捕捉设置: h! B3 ^- h, i
- (setvar "osmode" 0) ;关闭对象捕捉
* F6 u; e$ r; t1 w3 k& k - (setvar "cmdecho" 0)
6 d$ {- s, M; Z1 s - (setq e (entsel "\n选择要对分的板筋: "))
8 f" R1 p+ l A8 o9 \; c - (setq ent (entget (car e)))
( Q9 \8 s. k2 l# v! w5 m5 D - (setq newt (atoi (cdr (assoc 1 ent))))& q% b5 {0 z: U7 M8 Q; j7 K! a1 ]" T
- (if (/= 0 newt) ;过滤非数值文字' o2 g7 n4 l. C
- (progn
6 v1 k& j7 ? ~' ]0 Y9 D - (setq tc (cdr (assoc 8 ent))) ;提取图层信息
* H% S. p, v% H; S/ S1 w - (command "._Clayer" tc) ;保持图层一致
' k* l+ F- }! M9 E - (setq mc (cdr (assoc -1 ent))) ;提取名称,删除原对象使用, y! \4 e, q) r P! `
- (setq ang (cdr (assoc 50 ent))) ;提取文字角度9 v% T3 x9 U: ^% d0 S3 @
- (setq st (cdr (assoc 7 ent))) ;提取文字样式
O& ?' `0 ]! C3 t3 c - (setq zb (cdr (assoc 10 ent))) ;提取文字起点坐标5 X2 y% t' d+ Y. y
- (setq zbx (car zb)) ;文字x坐标3 v# j. E* L6 b0 t5 r1 {' R
- (setq zby (cadr zb)) ;文字Y坐标1 g# J* Y/ G7 b! L x
- (setq zg (cdr (assoc 40 ent))) ;提取字高
' k4 j' _! ~+ `! `5 A- b - (setq zb1x (+ zbx (* 0.25 newt (cos ang))))
* V- b z+ n. w2 Q1 \2 [ - ;计算分开后两个数值的文字起点
+ v3 u7 F2 G2 [" [ - (setq zb1y (+ zby (* 0.25 newt (sin ang)))), i' V, @8 T, @ y' x% Y! B. r# T
- (setq zb2x (- zbx (* 0.25 newt (cos ang))))
3 h( c6 E3 c1 h9 ?$ ^& q. m" G - (setq zb2y (- zby (* 0.25 newt (sin ang))))5 n! t9 S! a5 K- E" [$ c
- (setq zb1 (list zb1x zb1y)) ;确定坐标点- \; }0 M" K( V& a$ M
- (setq zb2 (list zb2x zb2y))/ d( j! d- ?" v/ |
- (if (= (cdr (assoc 40 (entget (tblobjname "style" st)))) 0)
( p. {# a: X( R - ;查看该文字样式中文字高度是否为0
' W$ s6 K: @% n - (progn ;文字样式中文字高度为0时使用原对象的文字高度
- z: e) z& D+ c; L7 ^: z# I4 o - (command "text" "s" st zb1 zg (* 180 (/ ang pi)) (/ newt 2))! i- N' w" t8 a" _+ y
- ;输入两个对分的数值
) {. {* j" I1 V4 O' M - (command "text" "s" st zb2 zg (* 180 (/ ang pi)) (/ newt 2))
" f/ ?9 r& X( c3 s I - )3 {+ z1 y0 D0 j) @3 j9 D4 f, ?
- (progn ;文字样式中文字高度不为0时不在命令行中指定文字高度9 c' K' b: ]% a
- (command "text" "s" st zb1 (* 180 (/ ang pi)) (/ newt 2))/ ?7 O: X( W( ^5 U
- ;输入两个对分的数值
: F4 Y- H9 H% V1 v ?1 y, b - (command "text" "s" st zb2 (* 180 (/ ang pi)) (/ newt 2))
3 S# U) K6 Z- ]" u6 ?! N - )
1 G' {9 H' j% N. Q - )6 A9 t" J2 I6 B( y2 y3 m& f
- (entdel mc) ;删除原对象
' Q; I* I! O' C2 M4 ? - )+ y" a+ _* G8 E2 @+ ]: l
- (princ "\n所选对象不能处理")" d; V I' T. g7 ^) ?
- )
$ |, E$ p/ ?) I - (setvar "osmode" oldosmode) ;恢复用户对象捕捉设置
8 `% C4 D. Z S! s/ j: n* ? - (setvar "cmdecho" 1) x# a" U$ U( N* {. @ U; d
- (princ)
) z6 W) Q, s" T- V - )
复制代码 |
|