乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 82|回复: 2

[编程交流] vlax调用与catc相交

[复制链接]

46

主题

92

帖子

45

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
235
发表于 2022-7-5 15:36:20 | 显示全部楼层 |阅读模式
我在分析李的功能。
  1. http://www.lee-mac.com/intersectionfunctions.html
  1. ;; Intersections  -  Lee Mac
  2. ;; Returns a list of all points of intersection between two objects
  3. ;; for the given intersection mode.
  4. ;; ob1,ob2 - [vla] VLA-Objects
  5. ;;     mod - [int] acextendoption enum of intersectwith method
  6. (defun LM:intersections ( ob1 ob2 mod / lst rtn )
  7.    (if (and (vlax-method-applicable-p ob1 'intersectwith)
  8.             (vlax-method-applicable-p ob2 'intersectwith)
  9.             (setq lst (vlax-invoke ob1 'intersectwith ob2 mod))
  10.        )
  11.        (repeat (/ (length lst) 3)
  12.            (setq rtn (cons (list (car lst) (cadr lst) (caddr lst)) rtn)
  13.                  lst (cdddr lst)
  14.            )
  15.        )
  16.    )
  17.    (reverse rtn)
  18. )

我注意到,如果坐标较大,该函数将捕捉相邻的段。
 
 
示例1:两条多段线相交。
 
163625ig4ytejdegcgieis.jpg
 
  1. (LM:intersections (vlax-Ename->Vla-Object (car (entsel))) (vlax-Ename->Vla-Object (car (entsel))) acextendnone)

 
  1. LWPOLYLINE 1: ((-0.112 0.093) (0.296 0.085) (0.717 0.255))
  2. LWPOLYLINE 2: ((-0.043 0.177) (0.08 0.003) (0.234 0.177) (0.323 -0.022) (0.373 0.227))

 
返回4个正确的点。
 
  1. ((0.0180291 0.090385 0.0) (0.155541 0.0875826 0.0) (0.275268 0.0851427 0.0) (0.34906 0.106104 0.0))

 
示例2:转换的两条LW多段线的交点。
 
  1. LWPOLYLINE 1: ((8405375.127 5679451.655) (8405375.535 5679451.647) (8405375.955 5679451.818))
  2. LWPOLYLINE 2: ((8405375.195 5679451.739) (8405375.319 5679451.565) (8405375.473 5679451.739) (8405375.562 5679451.54) (8405375.612 5679451.789))

 
返回6分。4正确,2不正确。
 
  1. ((8.40538e+006 5.67945e+006 0.0) (8.40538e+006 5.67945e+006 0.0) (8.40538e+006 5.67945e+006 0.0) (8.40538e+006 5.67945e+006 0.0) (8.40538e+006 5.67945e+006 0.0) (8.40538e+006 5.67945e+006 0.0))

 
计算交点时,将对象移动到坐标系起点的唯一解决方案是什么?
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 16:16:44 | 显示全部楼层
不幸的是,这是intersectwith方法的一个已知错误-前面已经讨论过。
回复

使用道具 举报

66

主题

1552

帖子

1514

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
325
发表于 2022-7-5 16:45:56 | 显示全部楼层
有趣的是,但是我无法复制这个bug。。。
我想建议使用像李提供的polyinters这样的函数(不知道他已经写了这样的东西)。
 
我所知道的intersectwith方法的唯一失败是:
  1. (setq rtn ; in case the object is self intersecting
  2. (cons  ; but the problem is that this considers LWPOLY's/SPLINE's mid vertices as intersections (i.e. all vertices, except the endpoints)
  3.    (vlax-list->3D-point (vlax-invoke o1 'InterSectWith o1 acExtendNone))
  4.    rtn
  5. )
  6. ); setq rtn

 
顺便说一句,Lee函数的一种变体,使用vlax curveGetPointAtParam在分段处分割曲线,并对两个曲线对象的每对分段使用inters,可能“完成了这项工作”,尽管这种方法在精度和速度性能上会有所不同。也许这个想法更有效的方法是把它和这个结合起来。
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-14 21:08 , Processed in 0.434275 second(s), 72 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表