请问如何删除一条多段线和块图重合的部分?
DocumentLock docLock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();Database db = HostApplicationServices.WorkingDatabase;
Entity acadEntity = null; Entity poleped = null;
using (Transaction trans = db.TransactionManager.StartTransaction())
{
acadEntity = (Entity)trans.GetObject(strandobjectid, OpenMode.ForWrite);
poleped = (Entity)trans.GetObject(PoleObjId, OpenMode.ForWrite);
// if (poleped == null)
// return;
BlockReference br = poleped as BlockReference;
if (acadEntity is Polyline)
{
Polyline strand = acadEntity as Polyline;
Point3dCollection m_ints = new Point3dCollection();
strand.IntersectWith(br, Intersect.OnBothOperands, new Plane(), m_ints, 0, 0);
foreach (Point3d m_pt in m_ints)
{
//br. strand.StartPoint
if (IsStartPoint)
{
strand.AddVertexAt(0, new Point2d(m_pt.X, m_pt.Y), 0, 0, 0);
strand.RemoveVertexAt(1);
}
else
{
int count = strand.NumberOfVertices;
strand.AddVertexAt(count - 1, new Point2d(m_pt.X, m_pt.Y), 0, 0, 0);
strand.RemoveVertexAt(count);
}
break;
}
}
} 开头重合的可以删除 结尾就不行了
int count = strand.NumberOfVertices;
我只有3个段点怎么count=4啊
Editor ced = aApp.DocumentManager.MdiActiveDocument.Editor;
Database cdb = aApp.DocumentManager.MdiActiveDocument.Database;
Autodesk.AutoCAD.DatabaseServices.TransactionManager ctm = aApp.DocumentManager.MdiActiveDocument.Database.TransactionManager;
Point3dCollection p3ds = new Point3dCollection();
p3ds.Add(pStart);
sPolylineJig jig = new sPolylineJig(p3ds);
int pcount = p3ds.Count;
ced.Drag(jig);
while (jig.Status == 1)
{
p3ds = new Point3dCollection();
for (int i = 0; i <= pcount; i++)
{
p3ds.Add(((aPolyline)jig.Entity).GetPoint3dAt(i));
}
jig = new sPolylineJig(p3ds);
pcount += 1;
ced.Drag(jig);
}
p3ds.Add(pEnd);
pcount += 1;
jig = new sPolylineJig(p3ds);
if (jig.Status == 0)
return;
ObjectId newBtrId = new ObjectId();
using (Transaction ctrans = ctm.StartTransaction())
{
DocumentLock docLock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
BlockTable cbt = (BlockTable)ctm.GetObject(cdb.BlockTableId, OpenMode.ForRead, false);
BlockTableRecord cbtr = (BlockTableRecord)ctm.GetObject(cbt, OpenMode.ForWrite, false);
newBtrId=cbtr.AppendEntity(jig.GetEntity());
ctm.AddNewlyCreatedDBObject(jig.GetEntity(), true);
DBObject obj = ctrans.GetObject(newBtrId, OpenMode.ForWrite);
XDataDispose.AddRegAppTableRecord("xlentComms");
ResultBuffer rb = new ResultBuffer(
new TypedValue(1001, "xlentComms"),
new TypedValue(1000, elementid + "," + Asbuild_Keys.strandEnt)
);
obj.XData = rb;
rb.Dispose();
ctrans.Commit();
cdb.SaveAs(ced.Document.Name, true, DwgVersion.Current, cdb.SecurityParameters);
pObjId = newBtrId;
docLock.Dispose();
}
jig.Entity.Dispose();
p3ds.Dispose(); 没人知道么?
页:
[1]