paulpipi 发表于 2023-2-27 08:53
大神,有试出来吗?
通过咨询上面的大佬
自己做了个勉强能用的,贴出来你看看
/// <summary>
/// 判断两个曲线的包围关系,如果是被包围的曲线就改变颜色为黄色
/// </summary>
/// <param name="curve1">曲线1</param>
/// <param name="curve2">曲线2</param>
public static void IsPolygonInsideAnotherPolygon(Curve curve1, Curve curve2)
{
Point3d point1;
Point3d point2;
MPolygon mPolygon1 = new MPolygon();
MPolygon mPolygon2 = new MPolygon();
if (curve1.GetType() == typeof(Polyline))
{
Polyline polyline1 = (Polyline)curve1;
mPolygon1.AppendLoopFromBoundary(polyline1, false, Tolerance.Global.EqualPoint);
point1 = polyline1.GetPoints().ToList();
}
else
{
Circle c1 = (Circle)curve1;
mPolygon1.AppendLoopFromBoundary(c1, false, Tolerance.Global.EqualPoint);
point1 = c1.StartPoint;
}
if (curve2.GetType() == typeof(Polyline))
{
Polyline polyline2 = (Polyline)curve2;
mPolygon2.AppendLoopFromBoundary(polyline2, false, Tolerance.Global.EqualPoint);
point2 = polyline2.GetPoints().ToList();
}
else
{
Circle c2 = (Circle)curve2;
mPolygon2.AppendLoopFromBoundary(c2, false, Tolerance.Global.EqualPoint);
point2 = c2.StartPoint;
}
if (mPolygon1.IsPointInsideMPolygon(point2, Tolerance.Global.EqualPoint).Count == 1)
{
curve2.ForWrite(e => e.ColorIndex = 2);
}
else if (mPolygon2.IsPointInsideMPolygon(point1, Tolerance.Global.EqualPoint).Count == 1)
{
curve1.ForWrite(e => e.ColorIndex = 2);
}
else return; qq25469005 发表于 2023-2-27 14:53
通过咨询
自己做了个勉强能用的,贴出来你看看
内部图元改为黄色后,选择的时候用选择过滤器过滤黄色的图元,大概就差不多实现了这个效果,就是图元太多的时候效率稍慢一点 qq25469005 发表于 2023-2-27 14:53
通过咨询上面的大佬
自己做了个勉强能用的,贴出来你看看
试了一下,出现:错误: no function definition: CURVE,大神能搞个完整的出来吗?谢谢分享! 本帖最后由 qq25469005 于 2023-2-28 13:30 编辑
paulpipi 发表于 2023-2-27 20:54
试了一下,出现:错误: no function definition: CURVE,大神能搞个完整的出来吗?谢谢分享!
这个要使用ifoxcad开发
/// <summary>
/// 改变被包围的图元颜色为黄色
/// </summary>
public void WaiKuang()
{
using DBTrans tr = new();
var ents = Env.Editor.SSGet().Value.GetEntities<Curve>().ToList();
//ents.ForEach(t=>t.ForWrite(e => e.CloseCurve(tr)));
for(var i = 0; i < ents.Count-1; i++)
{
for(var j = i+1;j<ents.Count;j++)
{
Q_EntityEx.IsPolygonInsideAnotherPolygon(ents, ents);
}
}
}
页:
1
[2]