本帖最后由 自贡黄明儒 于 2010-12-9 19:30 编辑
对于样条曲线相交的两条线,如果不平行,则调用 _dimangular,是可以显示两交点之间距离的
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;弧长标注 (defun C:CC () (setvar "modemacro" "自贡运机集团") (lt:error-init (list nil 0 nil)) (HH:cc) (lt:error-restore) (gc) ;释放内存 (princ "\n自贡运机集团 黄明儒:We must do the best with what God gave us!" ) (princ) )
;;;;;;;;;;;;;;;;;;;弧长标注 (defun HH:cc ( / ANG1 ANG2 BOOL DXF ENT1 NEW OBJ PARAM POINT1 POINT2 VAR1 VAR2)
(setvar "cmdecho" 0) ;不显示命令提示 (setq var1 (getvar "osmode")) (setq var2 (getvar "autosnap")) (setvar "autosnap" 39) (vl-load-com) (setq bool T) (while bool (setq ent1 (entsel "\n>点击欲标注长度的曲线:")) (if ent1 (setq bool nil) (princ "\n你点击的不是曲线,请点击曲线:") ) ) (setq obj (car ent1)) (setq obj (vlax-ename->vla-object obj))
(setvar "osmode" 33) ;交点或者端点 (setq point1 (getpoint "\n>>取得标注的第1个交点:")) (setq param (vlax-curve-getParamAtPoint obj point1)) (setq ang1 (angle (setq point1 (vlax-curve-getpointatparam obj param)) (mapcar '+ point1 (vlax-curve-getFirstDeriv obj param)) ) ) (setq point2 (getpoint "\n>>>取得标注的第2个交点:")) (setq param (vlax-curve-getParamAtPoint obj point2)) (setq ang2 (angle (setq point2 (vlax-curve-getpointatparam obj param)) (mapcar '+ point2 (vlax-curve-getFirstDeriv obj param)) ) ) (princ "\n>>>>标注放置点:") (setq bool (= ang1 ang2)) (if bool (command "dimaligned" point1 point2 pause ) (command "dimangular" point1 point2 pause ) ) (setq dxf (entget (entlast))) (setq new (- (vlax-curve-getDistAtPoint obj point1) (vlax-curve-getDistAtPoint obj point2) ) ) (setq new (abs new)) (if (<= (abs (- (cdr (assoc 42 dxf)) new)) 0.001) (setq bool t) (setq bool nil) ) (setq new (rtos new 2 (getvar "dimdec"))) (if bool (setq new (strcat "{\\fSimSun|b0|i0|c134|p2;}" new)) (setq new (strcat "{\\Fgdt.shx;^}\\P" new)) ) (setq dxf (subst (cons 1 new) (assoc 42 dxf) dxf)) (entmod dxf)
(setvar "autosnap" var2) (setvar "osmode" var1)
) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;弧长标注 |