明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 3795|回复: 2

如何得到框选范围内所有直线的交点?

[复制链接]
发表于 2004-9-27 13:35:00 | 显示全部楼层 |阅读模式
如何得到框选范围内所有直线的交点?


说说你的思路?
发表于 2004-9-27 13:42:00 | 显示全部楼层
(defun GetInterPoint (ent1 ent2 / intpoints points i)
(setq intpoints (vla-intersectwith ent1 ent2 acextendnone))
(setq intpoints (vlax-variant-value intpoints))
(setq i 0)
(if (> (vlax-safearray-get-u-bound intpoints 1) 0)
(repeat (/ (+ 1
(- (vlax-safearray-get-u-bound intpoints 1)
(vlax-safearray-get-l-bound intpoints 1)
)
)
3
)
(setq points (append points (list (list
(vlax-safearray-get-element intpoints i)
(vlax-safearray-get-element intpoints (+ i 1))
(vlax-safearray-get-element intpoints (+ i 2))
)))
)
(setq i (+ 3 i))
)
)
points
) (defun c:main( / ss n i j ent1 ent2 points)
(setq ss (ssget))
(if ss
(setq n (sslength ss))
)
(setq i 0 j 0)
(while (< i n)
(setq j (1+ i))
(setq ent1 (ssname ss i))
(while (< j n)
(setq ent2 (ssname ss j))
(setq points (append points (getinterpoint ent1 ent2)))
(setq j (1+ j))
)
(setq i (1+ i))
)
(Princ points)
(princ (strcat "\n共有交点" (itoa (length points)) "个"))
(princ)
)
发表于 2004-9-27 16:53:00 | 显示全部楼层
小小修正 (defun GetInterPoint (ent1 ent2 / intpoints points i) (setq intpoints (vla-intersectwith ent1 ent2 acextendnone))
(setq intpoints (vlax-variant-value intpoints))
(setq i 0)
(if (> (vlax-safearray-get-u-bound intpoints 1) 0)
(repeat (/ (+ 1
(- (vlax-safearray-get-u-bound intpoints 1)
(vlax-safearray-get-l-bound intpoints 1)
)
)
3
)
(setq points (append points (list (list
(vlax-safearray-get-element intpoints i)
(vlax-safearray-get-element intpoints (+ i 1))
(vlax-safearray-get-element intpoints (+ i 2))
)))
)
(setq i (+ 3 i))
)
)
points
) (defun c:main( / ss n i j ent1 ent2 points)
(setq ss (ssget))
(if ss
(setq n (sslength ss))
)
(setq i 0 j 0)
(while (< i n)
(setq j (1+ i))
(setq ent1 (ssname ss i))
(setq ent1 (vlax-ename->vla-object ent1))
(while (< j n)
(setq ent2 (ssname ss j))
(setq ent2 (vlax-ename->vla-object ent2))
(setq points (append points (getinterpoint ent1 ent2)))
(setq j (1+ j))
)
(setq i (1+ i))
)
(Princ points)
(princ (strcat "\n共有交点" (itoa (length points)) "?"))
(princ)
)
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-18 16:50 , Processed in 0.181613 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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