AutoCAD.net: 如何实现裁剪功能–Trim

引自http://www.objectarx.net/bbs/viewthread.php?tid=1785&extra=page%3D1&page=2

public void TrimMap(Polyline cutBox)
{
    
//关闭对象捕捉功能避免误删除
    Application.SetSystemVariable(SNAPMODE0);
    Application.SetSystemVariable(
MODEMACRO正在修剪);
    
//获取最小与最大点
    Point3d minPoint = cutBox.GeometricExtents.MinPoint;
    Point3d maxPoint 
= cutBox.GeometricExtents.MaxPoint;
    
//设置缩放视口
    Tools.RunCommand(ZoomWnew Point3d(minPoint.X  10, minPoint.Y  100), new Point3d(maxPoint.X + 10, maxPoint.Y + 100));
    
//裁剪精度
    Polyline offsetBox = cutBox.GetOffsetCurves(0.2)[0as Polyline;
    
if (offsetBox.Area < cutBox.Area)
    
{
        offsetBox 
= cutBox.GetOffsetCurves(0.2)[0as Polyline;
    }

    
//裁剪
    for (int i = 0; i < offsetBox.NumberOfVertices; i++)
    
{
        Point3d p1 
= offsetBox.GetPoint3dAt(i);
        Point3d p2 
= new Point3d();
        
if (i == offsetBox.NumberOfVertices  1)
        
{
            p2 
= offsetBox.GetPoint3dAt(0);
        }

        
else
        
{
            p2 
= offsetBox.GetPoint3dAt(i + 1);
        }

        Tools.RunCommand(
TRIM, cutBox.ObjectId, “”F, p1, p2, “”“”);
    }

    offsetBox.Dispose();
    Application.SetSystemVariable(
MODEMACRO修剪完成);
}

版权声明:本文为wf225原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/wf225/archive/2008/08/07/1263206.html