<p> </p>
<p> </p>
<p><font face="Verdana"><br/>(defun C:XNJD (/ p1 p2 p3 p4 p5)<br/> (setq p1 (entsel "\n选取一段圆弧: ")) ;获取图元名<br/> (if p1<br/> (progn <br/> (setq p0 (entget (car p1))) ;获取图元表<br/> (setq p1 (cdr (assoc 0 p0))) ;获取表的0位置元素即类型ARC<br/> )<br/> )<br/> (if (/= p1 "ARC")<br/> (prompt "\n选择的不是圆弧,请再试...")<br/> )<br/> (setq CEN (cdr (assoc 10 p0))) ;获取圆弧圆心<br/> (setq RAD (cdr (assoc 40 p0))) ;获取圆弧半径<br/> (setq JDQ (cdr (assoc 50 p0))) ;获取起始角度<br/> (setq JDZ (cdr (assoc 51 p0))) ;获取终止角度</font></p>
<p><font face="Verdana"> (setq p1 (polar CEN JDQ RAD) ;获取圆弧起始点<br/> p2 (polar CEN JDZ RAD) ;获取圆弧终止点<br/> p3 (polar p1 (+ (/ pi 2) JDQ) RAD) ;获取起始点切线方向的半径点<br/> p4 (polar p2 (+ (/ pi 2) JDZ) RAD) ;获取终止点切线方向的半径点<br/> p5 (inters p1 p3 p2 p4 nil) ;切线交点<br/> )<br/> (if (not p5)<br/> (prompt "\n没有交点...")<br/> )<br/> (command "_.line" p1 p5 "")<br/> (command "_.line" p2 p5 "")</font></p>
<p><font face="Verdana"> (princ)<br/>)<br/></font></p> <p>你的图是比较理想的情况,实际上圆弧段的两个点不一定是切点。如果是求两个圆弧端点的切线的交点,那么只需要圆心和切点连接,然后转个90°可以求了。如果不是,那如何确定这个切点呢?</p>
一个用于修改特定块属性的程序
<p>方法1:</p><p>根据凸度段参数求圆心,由圆心与凸段两个端点求切线交点</p>
<p>方法2:</p>
<p>求凸度段前后两段直段端点,4个端点求交点(可以用数学方法,也可以用 lisp函数 inters)</p>
<p>方法 3:</p>
<p>(<font style="BACKGROUND-COLOR: #316ac5" color="#ffffff">vlax-curve</font>-getFirstDeriv <font style="BACKGROUND-COLOR: #316ac5" color="#ffffff">curve</font>-obj param)</p>
<p> </p> <span style="FILTER: glow(color='#A6BA98',strength='2'); WIDTH: 105px"><font color="#61b713" face="Verdana"><b>duotu007</b></font>已经解决了多余的切线部分,哪位大侠能修改成多段线的圆弧。</span> (defun c:test (/ LAST_OBJ LAST_SE OBJ OBJ_DATA OBJ_DATA_LIST OBJ_I OBJ_NAME)
(defun XNJD (p0 / CEN JDQ JDZ P1 P2 P3 P4 P5 RAD)
(setq CEN (cdr (assoc 10 p0))) ;获取圆弧圆心
(setq RAD (cdr (assoc 40 p0))) ;获取圆弧半径
(setq JDQ (cdr (assoc 50 p0))) ;获取起始角度
(setq JDZ (cdr (assoc 51 p0))) ;获取终止角度
(setq p1 (polar CEN JDQ RAD) ;获取圆弧起始点
p2 (polar CEN JDZ RAD) ;获取圆弧终止点
p3 (polar p1 (+ (/ pi 2) JDQ) RAD)
;获取起始点切线方向的半径点
p4 (polar p2 (+ (/ pi 2) JDZ) RAD)
;获取终止点切线方向的半径点
p5 (inters p1 p3 p2 p4 nil) ;切线交点
)
(if (not p5)
(prompt "\n没有交点...")
)
(command "_.line" p1 p5 "")
(command "_.line" p2 p5 "")
)
(setq obj (ssget '((0 . "*POLYLINE"))))
(if obj
(progn
(setq last_obj (ssget "p"))
(setq obj_data_list '())
(command "_undo" "mark")
(command "_explode" obj)
(setq last_se (ssget "p"))
(if (not (eq last_se last_obj))
(progn
(setq obj_i -1)
(repeat (sslength last_se)
(setq obj_name (ssname last_se (setq obj_i (1+ obj_i))))
(setq obj_data (entget obj_name))
(if (= (cdr (assoc 0 obj_data)) "ARC")
(progn
(setq obj_data_list
(append (list obj_data) obj_data_list)
)
)
)
)
)
)
(command "_undo" "back")
(if obj_data_list
(progn
(foreach i obj_data_list
(XNJD i)
)
)
)
)
)
(princ)
) 楼上的可用,我刚想把我的写出来呢,你比我快 不错,炸开之后,获取圆弧的属性 正是我想要的,赞一个
页:
1
[2]