duotu007 发表于 2010-6-1 10:21:00

<p>修改了下6楼的程序,单只能选择圆弧,单常用的多段线,哪位大侠能把多段线里的圆弧也加进去呢?</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><font face="Verdana"><br/>(defun&nbsp;C:XNJD (/ p1 p2 p3 p4 p5)<br/>&nbsp; (setq p1 (entsel "\n选取一段圆弧: ")) ;获取图元名<br/>&nbsp; (if p1<br/>&nbsp;&nbsp;&nbsp; (progn <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (setq p0 (entget (car p1)))&nbsp; ;获取图元表<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (setq p1 (cdr (assoc 0 p0)))&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;获取表的0位置元素即类型ARC<br/>&nbsp;&nbsp;&nbsp; )<br/>&nbsp; )<br/>&nbsp; (if (/= p1 "ARC")<br/>&nbsp;&nbsp;&nbsp; (prompt "\n选择的不是圆弧,请再试...")<br/>&nbsp; )<br/>&nbsp; (setq CEN (cdr (assoc 10 p0)))&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;获取圆弧圆心<br/>&nbsp; (setq RAD (cdr (assoc 40 p0)))&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;获取圆弧半径<br/>&nbsp; (setq JDQ (cdr (assoc 50 p0)))&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;获取起始角度<br/>&nbsp; (setq JDZ (cdr (assoc 51 p0)))&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;获取终止角度</font></p>
<p><font face="Verdana">&nbsp; (setq p1 (polar CEN JDQ RAD)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;获取圆弧起始点<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; p2 (polar CEN JDZ RAD)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;获取圆弧终止点<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; p3 (polar p1 (+ (/ pi 2) JDQ) RAD)&nbsp; ;获取起始点切线方向的半径点<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; p4 (polar p2 (+ (/ pi 2) JDZ) RAD)&nbsp; ;获取终止点切线方向的半径点<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; p5 (inters p1 p3 p2 p4 nil)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;切线交点<br/>&nbsp; )<br/>&nbsp; (if (not p5)<br/>&nbsp;&nbsp;&nbsp; (prompt "\n没有交点...")<br/>&nbsp;&nbsp; )<br/>&nbsp;(command "_.line" p1 p5 "")<br/>&nbsp;(command "_.line" p2 p5 "")</font></p>
<p><font face="Verdana">&nbsp; (princ)<br/>)<br/></font></p>

sailorcwx 发表于 2010-6-1 11:54:00

<p>你的图是比较理想的情况,实际上圆弧段的两个点不一定是切点。如果是求两个圆弧端点的切线的交点,那么只需要圆心和切点连接,然后转个90°可以求了。如果不是,那如何确定这个切点呢?</p>

狂刀无痕 发表于 2010-6-1 14:47:00

一个用于修改特定块属性的程序

<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>&nbsp;</p>

linshiyin2 发表于 2010-6-1 14:58:00

<span style="FILTER: glow(color='#A6BA98',strength='2'); WIDTH: 105px"><font color="#61b713" face="Verdana"><b>duotu007</b></font>已经解决了多余的切线部分,哪位大侠能修改成多段线的圆弧。</span>

gufeng 发表于 2010-6-1 15:52:00

(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)
)

linshiyin2 发表于 2010-6-1 15:57:00

楼上的可用,我刚想把我的写出来呢,你比我快

zwf100 发表于 2016-8-6 23:06:13

不错,炸开之后,获取圆弧的属性

技术工作室 发表于 2023-10-3 19:33:29

正是我想要的,赞一个
页: 1 [2]
查看完整版本: [求助]如何画出圆弧的两个切线