|
发表于 2011-11-29 13:36:09
|
显示全部楼层
- (defun c:bdf (/ e ent tc newt mc ang st zb
, m" ], W9 Y) k6 @9 A B0 _ - zbx zby zg zb1x zb1y zb2x zb2y zb1 zb20 `1 E5 K; z2 C
- oldosmode$ e2 @. N" C; Y1 x2 Q
- )8 k, B8 v) h* @8 u- K& ~1 O) H2 M
- (setq oldosmode (getvar "osmode")) ;记录用户当前的对象捕捉设置7 \! V% Q6 j1 i& ?6 p& E" T, O* a
- (setvar "osmode" 0) ;关闭对象捕捉
+ q2 f2 Q! Y" `- h - (setvar "cmdecho" 0)
! H' p6 Q$ y7 X" L - (setq e (entsel "\n选择要对分的板筋: "))2 B& t' M% ~, X% q* n! C% g6 v
- (setq ent (entget (car e)))# d) H/ E$ g: R! k
- (setq newt (atoi (cdr (assoc 1 ent))))
3 e# U" t x: M, R# O$ u - (if (/= 0 newt) ;过滤非数值文字' W) N0 b! ]0 V5 _0 F, n
- (progn
7 v) j3 n! B, E - (setq tc (cdr (assoc 8 ent))) ;提取图层信息
# m8 B# |- x7 ^) ?; _ - (command "._Clayer" tc) ;保持图层一致
+ v9 x3 [' ?% B2 u8 U( ]3 E$ ]( K- w - (setq mc (cdr (assoc -1 ent))) ;提取名称,删除原对象使用+ f* B7 r+ b0 K0 }6 s( H1 c
- (setq ang (cdr (assoc 50 ent))) ;提取文字角度" Y8 P9 j. y' N4 n& B+ I/ u2 V
- (setq st (cdr (assoc 7 ent))) ;提取文字样式
7 c7 l2 n/ n, s3 ?) v( O+ L( m - (setq zb (cdr (assoc 10 ent))) ;提取文字起点坐标; l: D) m4 N: v
- (setq zbx (car zb)) ;文字x坐标
5 k2 w5 G k+ I3 B/ U. L/ j - (setq zby (cadr zb)) ;文字Y坐标 h7 g. L N; _4 ^+ \
- (setq zg (cdr (assoc 40 ent))) ;提取字高
! D" J% I# }8 y3 _+ H- B3 ] - (setq zb1x (+ zbx (* 0.25 newt (cos ang))))3 P: A9 G; A! x! J. f& k+ m
- ;计算分开后两个数值的文字起点3 H/ ]0 d5 _: r) l
- (setq zb1y (+ zby (* 0.25 newt (sin ang))))
5 R. Y& s- q7 ` - (setq zb2x (- zbx (* 0.25 newt (cos ang)))); l2 [* D: U, v% t0 d8 o
- (setq zb2y (- zby (* 0.25 newt (sin ang))))" F, R: |' {. |7 y9 g
- (setq zb1 (list zb1x zb1y)) ;确定坐标点
2 Y4 C5 W$ a" C" P - (setq zb2 (list zb2x zb2y))
7 M) S; x' H) t6 E8 c# f5 q- V# A# L - (if (= (cdr (assoc 40 (entget (tblobjname "style" st)))) 0)& e, |. \# f, e; S
- ;查看该文字样式中文字高度是否为06 [* j! x9 p5 y* T2 h
- (progn ;文字样式中文字高度为0时使用原对象的文字高度
- x! t/ V0 w( m9 J$ D9 J, B - (command "text" "s" st zb1 zg (* 180 (/ ang pi)) (/ newt 2))
# h7 S5 x& T" S) l4 F4 Y! G - ;输入两个对分的数值" v, s9 p* t' O* J6 t. R8 q$ h
- (command "text" "s" st zb2 zg (* 180 (/ ang pi)) (/ newt 2))
9 ^, m5 K V+ B. T, B; {/ W - )
3 S7 y, g5 j1 D3 A - (progn ;文字样式中文字高度不为0时不在命令行中指定文字高度
: e) D e' U8 h: z) K - (command "text" "s" st zb1 (* 180 (/ ang pi)) (/ newt 2))
* N) e W* P/ y/ k0 d% d - ;输入两个对分的数值. l( [. U8 v2 M& j w
- (command "text" "s" st zb2 (* 180 (/ ang pi)) (/ newt 2)): V% b( z0 ]# \
- )
$ o6 t, F7 ]5 p3 {% R6 ~( H - )- R8 K* Y2 J3 a9 A7 m [2 a& S7 k
- (entdel mc) ;删除原对象
; h: I$ \4 g. r. q - )
* M5 t8 E) z T/ F* x' [1 b - (princ "\n所选对象不能处理")
( @% L3 @8 k4 w) Y/ } - )* a! _/ r N0 j5 ]1 J) @5 Y
- (setvar "osmode" oldosmode) ;恢复用户对象捕捉设置
' M9 ^! ]3 u4 g% y E - (setvar "cmdecho" 1). U; m+ f7 H" H. S0 P% Q
- (princ)
3 E V( _7 X$ J- N4 I - )
复制代码 |
|