AutoCAD.net: 如何实现裁剪功能--Trim
AutoCAD.net: 如何实现裁剪功能–Trim
引自http://www.objectarx.net/bbs/viewthread.php?tid=1785&extra=page%3D1&page=2
{
//关闭对象捕捉功能避免误删除
Application.SetSystemVariable(“SNAPMODE“, 0);
Application.SetSystemVariable(“MODEMACRO“, “正在修剪“);
//获取最小与最大点
Point3d minPoint = cutBox.GeometricExtents.MinPoint;
Point3d maxPoint = cutBox.GeometricExtents.MaxPoint;
//设置缩放视口
Tools.RunCommand(“Zoom“, “W“, new Point3d(minPoint.X – 10, minPoint.Y – 10, 0), new Point3d(maxPoint.X + 10, maxPoint.Y + 10, 0));
//裁剪精度
Polyline offsetBox = cutBox.GetOffsetCurves(0.2)[0] as Polyline;
if (offsetBox.Area < cutBox.Area)
{
offsetBox = cutBox.GetOffsetCurves(–0.2)[0] as 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“, “修剪完成“);
}