;;以下是我自遍的粗糙度标注程序,加载后键入ROU,即可运行,供你参考
(defun c:rou (/ blip osd ira irt ip p0 p1 p2 p3 p4 p5 e e1 rouh zm #roughness)
(setq blip (getvar "blipmode"))
(setq oldlw (getvar "celweight"))
(setq osd (getvar "osmode"))
(setq oldsn (getvar "snapmode"))
(setvar "blipmode" 0)
(setvar "cmdecho" 0)
(setvar "celweight" 25)
(setvar "osmode" 0)
(setvar "snapmode" 0)
(if (not #text_high)
(setq #text_high (getstring (strcat "\n\n指定标注文字高 <" (rtos (getvar "dimtxt")) ">: ")
)
#text_high (cond ((= #text_high "") (getvar "dimtxt"))
(t (distof #text_high))
)
)
)
(initget 1)
(setq ip (getpoint "\n选择标注点: "))
(while ip
(setq p0 (osnap ip "nea"))
(setvar "osmode" 0)
(if p0
(setq ira (angle p0 ip))
(setq ira (* 0.5 pi)
p0 ip
)
)
(setq p1 (polar p0 (- ira (/ pi 6)) (* 3.2 #text_high)))
(setq p2 (polar p0 (- ira (/ pi 6)) (* 1.6 #text_high)))
(setq p3 (polar p0 (+ ira (/ pi 6)) (* 1.6 #text_high)))
(setq irt (cond ((> 3.142 ira 0) (- ira (* 0.5 pi)))
(t (+ ira (* 0.5 pi)))
)
)
(setq irt (/ (* irt 180) pi))
(command "undo" "be")
(command "pline" p2 "w" 0 "" p3 p0 p1 "")
(if (not #roughness)
(setq #roughness "3.2")
) ;if
(setq rouh (getstring (strcat "\n\n粗糙度数值 [非加工(0)]<" #roughness ">: "))) ;setq
(if (/= rouh "")
(setq #roughness rouh)
) ;if
(if (= #roughness "0")
;;非加工标注
(progn (entdel (entlast))
(command "pline" p3 p0 p1 "")
(setq e (entlast))
(setq p4 (polar p0 ira (* 0.92 #text_high)))
(command "circle" p4 (* 0.46 #text_high))
)
(progn (setq e (entlast))
;;加工面标注
(setq p5 (polar p0 ira (* 2.1 #text_high)))
(if (> (strlen #roughness) 3)
;;字符多于3,p5左移
(setq p5 (polar p5 (+ ira (* 0.5 pi)) (* 0.3 #text_high)))
)
(command "_text" "m" p5 #text_high irt #roughness)
)
)
(cond ((= p0 ip)
;;右上角简化标注
(setq zm (getstring "\n放大标注1.4倍 [是(Y)/否(N)]
:"))
(if (or (= zm "Y") (= zm "y") (= zm ""))
(command "scale" e (entlast) "" p0 1.4)
)
)
)
(setq ip (getpoint "\n下一标注点或 <退出>: "))
;;连续标注
)
(command "undo" "e")
(setvar "osmode" osd)
(setvar "cmdecho" 1)
(setvar "blipmode" blip)
(setvar "celweight" oldlw)
(setvar "snapmode" oldsn)
(princ)
)