当前位置: 服务支持 >  技术文档 >  CAD二次开发技术:IntersectWith应用

CAD二次开发技术:IntersectWith应用

阅读数 117
点赞 61
copyright 著作权
article_banner

IntersectWith用来寻找两个实体的交点

public unsafe void IntersectWith(
  Entity entityPointer,
  Intersect intersectType,
  Point3dCollection points,
  IntPtr thisGraphicSystemMarker,
  IntPtr otherGraphicSystemMarker)

此函数应用于两个Entity的简单相交,返回值为Entity的的点集

  • entityPointer:相交的另一个Entity

  • intersectType:计算交点的方式

    namespace Autodesk.AutoCAD.DatabaseServices {
      [Wrapper("AcDb::Intersect")]
      public enum Intersect  {
        OnBothOperands,
        ExtendThis,
        ExtendArgument,
        ExtendBoth,
      }
    }
    
    • Intersect.OnBothOperands :实际交点
    • Intersect.ExtendThis : 延长IntersectWith之前的Entity
    • Intersect.ExtendArgument : 延长entityPointer
    • Intersect.ExtendBoth : 两个都延长
  • points : 点集

  • thisGraphicSystemMarker :下级实体的图形系统标记,如果不适用就用缺省值IntPtr.Zero

  • otherGraphicSystemMarker :下级实体的图形系统标记,如果不适用就用缺省值IntPtr.Zero

示例程序

public static void IntersectWithTest () {

    Database db = HostApplicationServices.WorkingDatabase;
    Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
  
    Line line1 = new Line();
    line1.StartPoint = new Point3d(0, 0, 0);
    line1.EndPoint = new Point3d(0, 100, 0);
   
    Circle circle = new Circle();
    circle.Center = new Point3d(0, 0, 0);
    circle.Radius = 80;

    //放交点的集合
    Point3dCollection intersectionPoints1 = new Point3dCollection();
    line1.IntersectWith(circle, Intersect.OnBothOperands, intersectionPoints1, IntPtr.Zero,IntPtr.Zero);
    //intersectionPoints1 中有一个点 (0, 80, 0)
    Point3dCollection intersectionPoints2 = new Point3dCollection();
    circle.IntersectWith(line1, Intersect.OnBothOperands, intersectionPoints2, IntPtr.Zero, IntPtr.Zero);
    //intersectionPoints2 中有一个点 (0, 80, 0)

    Point3dCollection intersectionPoints3 = new Point3dCollection();
    line1.IntersectWith(circle, Intersect.ExtendThis, intersectionPoints3, IntPtr.Zero,IntPtr.Zero);
    //intersectionPoints3 中有两个点 (0, 80, 0)(0, -80, 0)
    Point3dCollection intersectionPoints4 = new Point3dCollection();
    circle.IntersectWith(line1, Intersect.ExtendThis, intersectionPoints4, IntPtr.Zero, IntPtr.Zero);
    //intersectionPoints4 中有一个点 (0, 80, 0)

    Point3dCollection intersectionPoints5 = new Point3dCollection();
    line1.IntersectWith(circle, Intersect.ExtendArgument, intersectionPoints5, IntPtr.Zero, IntPtr.Zero);
    //intersectionPoints5 中有一个点 (0, 80, 0)
    Point3dCollection intersectionPoints6 = new Point3dCollection();
    circle.IntersectWith(line1, Intersect.ExtendArgument, intersectionPoints6, IntPtr.Zero, IntPtr.Zero);
    //intersectionPoints6 中有两个点 (0, 80, 0)(0, -80, 0)

    Point3dCollection intersectionPoints7 = new Point3dCollection();
    line1.IntersectWith(circle, Intersect.ExtendBoth, intersectionPoints7, IntPtr.Zero, IntPtr.Zero);
    //intersectionPoints7 中有两个点 (0, 80, 0)(0, -80, 0)
    Point3dCollection intersectionPoints8 = new Point3dCollection();
    circle.IntersectWith(line1, Intersect.ExtendBoth, intersectionPoints8, IntPtr.Zero, IntPtr.Zero);
    //intersectionPoints8 中有两个点 (0, 80, 0)(0, -80, 0)

}
相关文章
QR Code
微信扫一扫,欢迎咨询~

联系我们
武汉格发信息技术有限公司
湖北省武汉市经开区科技园西路6号103孵化器
电话:155-2731-8020 座机:027-59821821
邮件:tanzw@gofarlic.com
Copyright © 2023 Gofarsoft Co.,Ltd. 保留所有权利
遇到许可问题?该如何解决!?
评估许可证实际采购量? 
不清楚软件许可证使用数据? 
收到软件厂商律师函!?  
想要少购买点许可证,节省费用? 
收到软件厂商侵权通告!?  
有正版license,但许可证不够用,需要新购? 
联系方式 155-2731-8020
预留信息,一起解决您的问题
* 姓名:
* 手机:

* 公司名称:

姓名不为空

手机不正确

公司不为空