明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1821|回复: 4

[求助]如何求出两条曲线的交点?

[复制链接]
发表于 2008-4-25 14:36:00 | 显示全部楼层 |阅读模式

Autolisp中如何返回两条曲线(圆弧或者多义线)的交点?

发表于 2008-4-25 17:33:00 | 显示全部楼层
在坛里搜索一下,有许多
 楼主| 发表于 2008-4-25 18:34:00 | 显示全部楼层
谢了。我试试
发表于 2008-4-25 19:14:00 | 显示全部楼层

;;;获取两条直线的交点
(defun c:ff ()
  (mycopyright)
  (vl-load-com)
  (setq ent1 (entsel "\n选择第一条曲线:"))
  (setq ent2 (entsel "\n选择第二条曲线:"))
  (setq ent_1 (car ent1)
 ent_2 (car ent2)
  )
  (setq int_list nil)
  (setq ax_ent_1 (vlax-ename->vla-object ent_1)
 ax_ent_2 (vlax-ename->vla-object ent_2)
  )
  (setq intpoints (vla-intersectwith ax_ent_1 ax_ent_2 acextendnone))
  (setq intpoints (vlax-variant-value intpoints))
  (if (> (vlax-safearray-get-u-bound intpoints 1) 0)
    (progn
      (setq i 0)
      (setq j 0)
      (setq disp "")
      (repeat
 (/ (+ 1
       (- (vlax-safearray-get-u-bound intpoints 1)
   (vlax-safearray-get-l-bound intpoints 1)
       )
    )
    3
 )
  (setq
    disp (list
    (vlax-safearray-get-element intpoints j)

    (vlax-safearray-get-element intpoints (+ 1 j))

    (vlax-safearray-get-element intpoints (+ 2 j))
  )
  )
  (setq i (+ 2 i)
        j (+ 3 j)
  )
  (setq int_list (append int_list (list disp)))
      )
    )
  )
  (setq int_list int_list)
)

发表于 2008-4-27 19:20:00 | 显示全部楼层
  1. (defun c:n (/ obj p1 p2 p3 li)
  2.   (setq obj (vlax-ename->vla-object (car (entsel "\ncurve: ")))
  3. p1  (trans (getpoint "\npoint 1: ") 1 0)
  4. p2  (trans (getpoint p1 "\npoint 2: ") 1 0)
  5. li  (vla-addline (vla-get-ModelSpace (vla-get-ActiveDocument (vlax-get-acad-object) ) ) (vlax-3d-point p1) (vlax-3d-point p2) )
  6. p3  (vlax-invoke obj 'IntersectWith li acExtendNone)
  7.   )
  8.   (if p3
  9.     (vla-put-EndPoint li (vlax-3d-point (list (car p3) (cadr p3) (caddr p3))))
  10.     (vla-delete li)
  11.   )
  12.   (princ)
  13. )
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-23 12:09 , Processed in 0.165575 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表