我正在创建一个窗口表单,用户将在Autocad中运行命令,它将提示他们选择一个对象(特别是三维多段线)。 3D折线可以具有非常广泛的顶点。我希望每个Vertex都在/创建它自己的行。每行有5列(每个Vertex的属性)。
适合使用的容器是什么?我希望用户能够修改(例如改变高程)每个顶点中的每个属性。与实际删除他们想要的任何顶点一起。
表布局面板?常规小组?这是我“获取”顶点的代码:
using (AcDb.Transaction oTr = db.TransactionManager.StartTransaction())
{
AcDb.ObjectIdCollection ids = new AcDb.ObjectIdCollection();
AcEd.PromptEntityOptions options = new AcEd.PromptEntityOptions("\nSelect a 3DPolyline:");
options.SetRejectMessage("That is not select a 3DPolyline" + "\n");
options.AddAllowedClass(typeof(AcDb.Polyline3d), true);
AcEd.PromptEntityResult result = ed.GetEntity(options);
if (result.Status != AcEd.PromptStatus.OK) return;
AcDb.Polyline3d oEnt = oTr.GetObject(result.ObjectId, AcDb.OpenMode.ForRead) as AcDb.Polyline3d;
foreach (AcDb.ObjectId oVtId in oEnt)
{
AcDb.PolylineVertex3d oVt = oTr.GetObject(oVtId, AcDb.OpenMode.ForRead) as AcDb.PolylineVertex3d;
//now to populate...something
答案 0 :(得分:3)
收集数据时,DataTable会有意义。
using (var trans = db.TransactionManager.StartTransaction())
{
var options = new PromptEntityOptions("\nSelect a 3DPolyline:");
options.SetRejectMessage("That is not select a 3DPolyline" + "\n");
options.AddAllowedClass(typeof(Polyline3d), true);
var result = ed.GetEntity(options);
if (result.Status != PromptStatus.OK)
return;
var poly = (Polyline3d)trans.GetObject(result.ObjectId, OpenMode.ForRead);
var vertexClass = RXClass.GetClass(typeof(PolylineVertex3d));
var vertexTable = new System.Data.DataTable("Vertices");
vertexTable.Columns.Add("HandleId", typeof(long));
vertexTable.Columns.Add("PositionX", typeof(double));
vertexTable.Columns.Add("PositionY", typeof(double));
vertexTable.Columns.Add("PositionZ", typeof(double));
foreach (ObjectId vertexId in poly)
{
if (!vertexId.ObjectClass.IsDerivedFrom(vertexClass))
continue;
var vertex = (PolylineVertex3d)trans.GetObject(vertexId, OpenMode.ForRead);
vertexTable.Rows.Add(vertex.Handle.Value, vertex.Position.X, vertex.Position.Y, vertex.Position.Z);
}
trans.Commit();
}
在表格中获得顶点数据后,您可以非常轻松地将其绑定到可视控件。