弧长标注、直线标注、样条曲线长度标注.....
我使用的autoCAD2004,09太慢了。<br/>我自己为2004编写了一个标注,在09下也可用 学习了,modemacro用法,LT:还不懂 不错啊!支持一下 <p>收藏了</p><p>享受一下楼主的分享</p>
<p>请问:不知弧长标注时能否做到没有圆心的一个小点?</p>
<p>望指教</p>
<p>谢谢楼主</p> 本程序只是调用了<font face="Verdana">_dimaligned和<font face="Verdana"> _dimangular</font>,然后计算两点间长度,至于你说的那个小点,可能是存在的</font> <p> </p>
<p>谢谢楼主</p>
<p>感觉还好用</p>
<p> </p> 收藏了 感谢分享 "样条曲线长度标注",太感谢了 <img alt="" src="http://bbs.mjtd.com/Skins/default/topicface/face1.gif"/>试了一下,提示选择直线、圆弧、圆标注,不能标注样条曲线 本帖最后由 自贡黄明儒 于 2010-12-9 19:30 编辑 <br /><br /><P>对于样条曲线相交的两条线,如果不平行,则调用<FONT face=Verdana> _dimangular</FONT>,是可以显示两交点之间距离的</P>
<P>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;弧长标注<BR>(defun C:CC ()<BR> (setvar "modemacro" "自贡运机集团")<BR> (lt:error-init (list nil 0 nil))<BR> (HH:cc)<BR> (lt:error-restore)<BR> (gc) ;释放内存<BR> (princ<BR> "\n自贡运机集团 黄明儒:We must do the best with what God gave us!"<BR> )<BR> (princ)<BR>)</P>
<P>;;;;;;;;;;;;;;;;;;;弧长标注<BR>(defun HH:cc ( / ANG1 ANG2 BOOL DXF ENT1 NEW OBJ PARAM POINT1 POINT2 VAR1 VAR2)</P>
<P> (setvar "cmdecho" 0) ;不显示命令提示<BR> (setq var1 (getvar "osmode"))<BR> (setq var2 (getvar "autosnap"))<BR> (setvar "autosnap" 39)<BR> (vl-load-com)<BR> (setq bool T)<BR> (while bool<BR> (setq ent1 (entsel "\n>点击欲标注长度的曲线:"))<BR> (if ent1<BR> (setq bool nil)<BR> (princ "\n你点击的不是曲线,请点击曲线:")<BR> )<BR> )<BR> (setq obj (car ent1))<BR> (setq obj (vlax-ename->vla-object obj))</P>
<P> (setvar "osmode" 33) ;交点或者端点<BR> (setq point1 (getpoint "\n>>取得标注的第1个交点:"))<BR> (setq param (vlax-curve-getParamAtPoint obj point1))<BR> (setq ang1<BR> (angle (setq point1 (vlax-curve-getpointatparam obj param))<BR> (mapcar '+ point1 (vlax-curve-getFirstDeriv obj param))<BR> )<BR> )<BR> (setq point2 (getpoint "\n>>>取得标注的第2个交点:"))<BR> (setq param (vlax-curve-getParamAtPoint obj point2))<BR> (setq ang2<BR> (angle (setq point2 (vlax-curve-getpointatparam obj param))<BR> (mapcar '+ point2 (vlax-curve-getFirstDeriv obj param))<BR> )<BR> )<BR> (princ "\n>>>>标注放置点:")<BR> (setq bool (= ang1 ang2))<BR> (if bool<BR> (command "dimaligned"<BR> point1<BR> point2<BR> pause<BR> )<BR> (command "dimangular"<BR> point1<BR> point2<BR> pause<BR> )<BR> )<BR> (setq dxf (entget (entlast)))<BR> (setq new (- (vlax-curve-getDistAtPoint obj point1)<BR> (vlax-curve-getDistAtPoint obj point2)<BR> )<BR> )<BR> (setq new (abs new))<BR> (if (<= (abs (- (cdr (assoc 42 dxf)) new)) 0.001)<BR> (setq bool t)<BR> (setq bool nil)<BR> )<BR> (setq new (rtos new 2 (getvar "dimdec")))<BR> (if bool<BR> (setq new (strcat "{\\fSimSun|b0|i0|c134|p2;}" new))<BR> (setq new (strcat "{\\Fgdt.shx;^}\\P" new))<BR> )<BR> (setq dxf (subst (cons 1 new) (assoc 42 dxf) dxf))<BR> (entmod dxf)</P>
<P> (setvar "autosnap" var2)<BR> (setvar "osmode" var1)</P>
<P>)<BR>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;弧长标注</P> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;弧长标注
(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 E E1 ENTS
H N NEW OBJ P1 P3 PARAMPAUSE
POINT1 POINT2 STD1 VAR1 VAR2
)
(setvar "cmdecho" 0) ;不显示命令提示
(setq var1 (getvar "osmode"))
(setq var2 (getvar "autosnap"))
(setvar "autosnap" 39)
(setvar "osmode" 33) ;交点或者端点
(vl-load-com)
(setq std1 (list ())) ;空表
(setq point1 (getpoint "\n>取得标注的第1个交点:"))
(setq h (* (/ (getvar "viewsize") (cadr (getvar "screensize")))
(getvar "pickbox")
)
)
(setq p1 (mapcar '- point1 (list h h 0.))
p3 (mapcar '+ point1 (list h h 0.))
)
(setq ents (ssget "C" p1 p3)
n 0
)
(repeat (sslength ents)
(setq e (ssname ents n))
(setq e1 (entget e))
(if (not (= "DIMENSION" (cdr (assoc 0 e1))))
(setq std1 (append std1 (list e)))
)
(setq n (1+ n))
)
(setq point2 (getpoint "\n >>取得标注的第2个交点:"))
(setq p1 (mapcar '- point2 (list h h 0.))
p3 (mapcar '+ point2 (list h h 0.))
)
(setq ents (ssget "C" p1 p3)
n 0
)
(setq bool T)
(while bool
(setq obj (ssname ents n))
(if (setq new (member obj std1))
(setq bool nil)
)
(setq n (1+ n))
)
(setq obj (vlax-ename->vla-object obj))
(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 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>>>>标注放置点:")
(setvar "autosnap" var2)
(setvar "osmode" var1)
(setq bool (getpoint "\n>>>>标注尺寸放置点:"))
(if (= ang1 ang2)
(command "dimaligned" point1 point2 bool)
(command "dimangular" point1 point2 bool)
)
(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)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;弧长标注
请问楼主CC命令可否标注一段整体弧长中的两点间的距离