明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
12
返回列表 发新帖
楼主: qq25469005

[选集] 框选的时候只选择边界线

[复制链接]
 楼主| 发表于 2023-2-27 14:53 | 显示全部楼层
本帖最后由 qq25469005 于 2023-2-27 14:56 编辑
paulpipi 发表于 2023-2-27 08:53
大神,有试出来吗?

通过咨询上面的大佬
自己做了个勉强能用的,贴出来你看看

  1. /// <summary>
  2.     /// 判断两个曲线的包围关系,如果是被包围的曲线就改变颜色为黄色
  3.     /// </summary>
  4.     /// <param name="curve1">曲线1</param>
  5.     /// <param name="curve2">曲线2</param>
  6.     public static void IsPolygonInsideAnotherPolygon(Curve curve1, Curve curve2)
  7.     {

  8.         
  9.         Point3d point1;
  10.         Point3d point2;

  11.         MPolygon mPolygon1 = new MPolygon();
  12.         MPolygon mPolygon2 = new MPolygon();
  13.         if (curve1.GetType() == typeof(Polyline))
  14.         {
  15.             Polyline polyline1 = (Polyline)curve1;
  16.             mPolygon1.AppendLoopFromBoundary(polyline1, false, Tolerance.Global.EqualPoint);
  17.            
  18.             point1 = polyline1.GetPoints().ToList()[0];
  19.         }
  20.         else
  21.         {
  22.             Circle c1 = (Circle)curve1;
  23.             mPolygon1.AppendLoopFromBoundary(c1, false, Tolerance.Global.EqualPoint);
  24.             point1 = c1.StartPoint;
  25.         }

  26.         if (curve2.GetType() == typeof(Polyline))
  27.         {
  28.             Polyline polyline2 = (Polyline)curve2;
  29.             mPolygon2.AppendLoopFromBoundary(polyline2, false, Tolerance.Global.EqualPoint);
  30.          
  31.             point2 = polyline2.GetPoints().ToList()[0];
  32.         }
  33.         else
  34.         {
  35.             Circle c2 = (Circle)curve2;
  36.             mPolygon2.AppendLoopFromBoundary(c2, false, Tolerance.Global.EqualPoint);
  37.             point2 = c2.StartPoint;
  38.         }

  39.       
  40.         




  41.         if (mPolygon1.IsPointInsideMPolygon(point2, Tolerance.Global.EqualPoint).Count == 1)
  42.         {
  43.             
  44.             curve2.ForWrite(e => e.ColorIndex = 2);
  45.         }
  46.         else if (mPolygon2.IsPointInsideMPolygon(point1, Tolerance.Global.EqualPoint).Count == 1)
  47.         {
  48.             
  49.             curve1.ForWrite(e => e.ColorIndex = 2);
  50.         }
  51.         else return;
复制代码
 楼主| 发表于 2023-2-27 14:54 | 显示全部楼层
qq25469005 发表于 2023-2-27 14:53
通过咨询
自己做了个勉强能用的,贴出来你看看

内部图元改为黄色后,选择的时候用选择过滤器过滤黄色的图元,大概就差不多实现了这个效果,就是图元太多的时候效率稍慢一点
发表于 2023-2-27 20:54 | 显示全部楼层
qq25469005 发表于 2023-2-27 14:53
通过咨询上面的大佬
自己做了个勉强能用的,贴出来你看看

试了一下,出现:错误: no function definition: CURVE,大神能搞个完整的出来吗?谢谢分享!
 楼主| 发表于 2023-2-28 11:29 | 显示全部楼层
本帖最后由 qq25469005 于 2023-2-28 13:30 编辑
paulpipi 发表于 2023-2-27 20:54
试了一下,出现:错误: no function definition: CURVE,大神能搞个完整的出来吗?谢谢分享!

这个要使用ifoxcad开发
  1. /// <summary>
  2.     /// 改变被包围的图元颜色为黄色
  3.     /// </summary>
  4.     [CommandMethod("wk")]
  5.     public void WaiKuang()
  6.     {
  7.         using DBTrans tr = new();
  8.         var ents = Env.Editor.SSGet().Value.GetEntities<Curve>().ToList();
  9.         //ents.ForEach(t=>t.ForWrite(e => e.CloseCurve(tr)));
  10.         for(var i = 0; i < ents.Count-1; i++)
  11.         {
  12.             for(var j = i+1;j<ents.Count;j++)
  13.             {
  14.                 Q_EntityEx.IsPolygonInsideAnotherPolygon(ents[i], ents[j]);
  15.             }
  16.         }
  17.     }
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-4-20 12:56 , Processed in 2.450254 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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