下面的C#示例可能會對您有所幫助。它不會使用大師級的,但這應該大致完成你所需要的。
var data = new[]
{
new {FID = 0, ShapeNum = 1, X = 0.0, Y = 0.0},
new {FID = 1, ShapeNum = 1, X = 1.0, Y = 0.0},
new {FID = 2, ShapeNum = 1, X = 1.0, Y = 1.0},
new {FID = 3, ShapeNum = 1, X = 0.0, Y = 1.0},
new {FID = 4, ShapeNum = 1, X = 0.0, Y = 0.0},
new {FID = 5, ShapeNum = 2, X = 5.0, Y = 5.0},
new {FID = 6, ShapeNum = 2, X = 6.0, Y = 5.0},
new {FID = 7, ShapeNum = 2, X = 6.0, Y = 6.0},
new {FID = 8, ShapeNum = 2, X = 5.0, Y = 6.0},
new {FID = 9, ShapeNum = 2, X = 5.0, Y = 5.0}
};
// group by shapenum
var data2 = from record in data
group record by record.ShapeNum
into g
select new {ShapeNum = g.Key, Records = g}
;
var app = new Microsoft.Office.Interop.Visio.ApplicationClass();
var doc = app.Documents.Add("");
var page = doc.Pages[1];
foreach (var g in data2)
{
var sorted_records = g.Records.OrderBy(i => i.FID).ToList();
var doubles = new List<double>();
foreach (var r in sorted_records)
{
doubles.Add(r.X);
doubles.Add(r.Y);
}
page.DrawPolyline(doubles.ToArray(), 0);
}
謝謝@Saveenr。如何使用* .csv文件獲取座標?我所顯示的表格是一個外部數據集,並且有兩個以上的形狀。 –
對於.NET代碼,我使用了CsvHelper:http://joshclose.github.io/CsvHelper/ – saveenr