明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 224|回复: 4

[提问] atuolisp 两条空间错位的线或其他对象,计算点上的交点

[复制链接]
发表于 3 天前 | 显示全部楼层 |阅读模式
例如三维空间线不存在交点,但窗口能看到相交,计算线上的交点

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
 楼主| 发表于 3 天前 | 显示全部楼层
生成统一平面的计算交点,再返回到线上,但存在个bug,vlax-curve-getClosestPointTo 是垂直方向最近点,存在狠斜时坐标返回错位,使用vlax-curve-getClosestPointToProjection,部分情况下投影点也错了,还有其他方法吗
  1. (defun getIntersectwith        (obj          cutobj   /            typ             cpobj
  2.                          pte          pts           ptc            intPoints
  3.                          entobj          entcpobj objlen   ptcls    FunMap
  4.                          ptdt
  5.                         )
  6.   (defun FunMap        (x)
  7.     (vlax-curve-getClosestPointTo
  8.       obj
  9.       (ZC_GETCLOSESTPOINTTO obj x)
  10.       t
  11.     )
  12.   )
  13.   (setq intPoints (vlax-invoke obj 'intersectwith cutobj acextendnone))
  14.   ;;获取交点
  15.   (if (or (not intPoints) (= (type intPoints) vlax-vbEmpty))
  16.     (progn
  17.       (setq cpobj (CopynewObj obj))
  18.       (setq typ (vla-get-ObjectName obj))
  19.       (cond
  20.         ((MEMBER typ '("AcDbPolyline" "AcDb2dPolyline"))
  21.          (VLA-PUT-ELEVATION cpobj 0)
  22.         )
  23.         ((= typ "AcDbLine")
  24.          (set3dPtToZero cpobj "StartPoint")
  25.          (set3dPtToZero cpobj "endPoint")
  26.         )
  27.         ((MEMBER typ '("AcDbArc" "AcadEllipse"))
  28.          (set3dPtToZero cpobj "StartPoint")
  29.          (set3dPtToZero cpobj "endPoint")
  30.          (set3dPtToZero cpobj "Center")
  31.         )
  32.         ((= typ "AcDbCircle")
  33.          (set3dPtToZero cpobj "Center")
  34.         )
  35.         ((MEMBER typ '("AcDb3dPolyline" "AcDbMLine"))
  36.          (set3dPtstoZero cpobj "Coordinates")
  37.         )
  38.         ((= typ "AcDbSpline")
  39.          (set3dPtstoZero cpobj "FitPoints")
  40.         )
  41.         ((MEMBER typ '("AcDbRay " "AcDbXline "))
  42.          (set3dPtToZero cpobj "BasePoint")
  43.          (set3dPtToZero cpobj "SecondPoint")
  44.         )
  45.       )
  46.       (setq intPoints
  47.              (vlax-invoke cpobj 'intersectwith cutobj acextendnone)
  48.       )
  49.       (if (setq intPoints (LST3D->PTLIST intPoints))
  50.         (setq intPoints (mapcar 'FunMap intPoints))
  51.       )
  52.       (vla-delete cpobj)
  53.       (vl-remove 'nil intPoints)
  54.     )
  55.     (LST3D->PTLIST intPoints)
  56.   )
  57. )
发表于 3 天前 | 显示全部楼层
本帖最后由 kozmosovia 于 2024-9-27 15:51 编辑

平面交点处临时生成足够大的3dface或者垂直直线,再求三维线与3dface或者垂直线的交点。
要是求交的其中一条线是直线,直接做个直线垂直的3dface求交点,都不需要转平面求交点
 楼主| 发表于 3 天前 | 显示全部楼层
3dface 交叉情况时也不太好处理,例如绘制了个五角星
发表于 3 天前 | 显示全部楼层
那就是直接在平面交点绘制垂直线求实际交点了
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-9-30 10:30 , Processed in 0.159833 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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