嗨,吉尔!
1...它有什么理由为什么不在以下位置使用 JoinEntity:Autodesk.AutoCAD.DatabaseServices.Entity.JoinEntity(Autodesk.AutoCAD.DatabaseServices.Entity)
2...对我来说很难理解(在Acad API中有几个月的时间经验)类GeometryExtensions中的所有metods,你能解释一下,你如何加入例如Polylines(在你的情况下2d)
3...如果我尝试为Polyline3d设置PolylineSegmentCollection,我必须收集哪些属性我不确定
如何在AcadDB中命令“mjoin”中加入新的Polylines, 您是否正在删除并构建新的Polyline2d?!
抱歉有不好的问题,我是新手
A 第一次试用
- public PolylineSegmentCollection(Polyline3d pline)
- {
- ObjectId[] vertices = pline.Cast().ToArray();
- //PolylineVertex3d[] vertices = pline.Cast().ToArray();
- int n = vertices.Length - 1;
- for (int i = 0; i ().ToArray();
- ed.WriteMessage("\nNumber of vertexes: {0}", verts.Length);
- for (int i = 0; i < verts.Length; i++)
- {
- PolylineVertex3d vt = tr.GetObject(verts[i], OpenMode.ForRead) as PolylineVertex3d;
- coll.Add(new Point3d(vt.Position[0], vt.Position[1], vt.Position[2]));
- }
- tr.Commit();
- }
- return coll;
- }
- [CommandMethod("xx")]
- static public void Append3dPolylines()
- {
- Document doc = Application.DocumentManager.MdiActiveDocument;
- Editor ed = doc.Editor;
- Database db = doc.Database;
- Point3dCollection collPoint3d = null;
- Point3dCollection allPoint3d = null;
- PromptEntityOptions peo1 = new PromptEntityOptions("\nSelect source polyline : ");
- peo1.SetRejectMessage("\nInvalid selection...");
- peo1.AddAllowedClass(typeof(Autodesk.AutoCAD.DatabaseServices.Polyline3d), true);
- PromptEntityResult res = ed.GetEntity(peo1);
- if (PromptStatus.OK != res.Status)
- return;
- using (Transaction trans = db.TransactionManager.StartTransaction())
- {
- BlockTable BlkTbl = trans.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
- BlockTableRecord BlkTblRec = trans.GetObject(BlkTbl[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
- Polyline3d newPoly = new Polyline3d();
- BlkTblRec.AppendEntity(newPoly);
- trans.AddNewlyCreatedDBObject(newPoly, true);
- try
- {
- collPoint3d = GetVertex(res);
- allPoint3d = new Point3dCollection();
- foreach (Point3d pt in collPoint3d)
- {
- allPoint3d.Add(pt);
- }
- while (true)
- {
- PromptEntityOptions peo2 = new PromptEntityOptions("\nSelect polyline to join : ");
- peo2.SetRejectMessage("\nInvalid selection...");
- peo2.AddAllowedClass(typeof(Autodesk.AutoCAD.DatabaseServices.Polyline3d), true);
- res = ed.GetEntity(peo2);
- switch (res.Status)
- {
- case PromptStatus.OK:
- collPoint3d = GetVertex(res);
- foreach (Point3d pt in collPoint3d)
- {
- allPoint3d.Add(pt);
- }
- break;
- case PromptStatus.Cancel:
- foreach (Point3d pt in allPoint3d)
- {
- PolylineVertex3d vertex = new PolylineVertex3d(pt);
- newPoly.AppendVertex(vertex);
- trans.AddNewlyCreatedDBObject(vertex, true);
- }
- ed.WriteMessage("\nNew 3dPolyline created!");
- return;
- }
- }
- }
- catch (System.Exception ex)
- {
- ed.WriteMessage(ex.Message);
- }
- trans.Commit();
- }
- }
|