我有兴趣从Visio中的形状中找到几何数据(如下所示),这样我就可以将它导出到我可以在其他项目中使用的东西。问题是我希望能够画出东西……
要获得所选的形状,您可以使用 Selection 财产 Window 。一旦你有了这个,你可以用这样的东西遍历形状,部分和行(注意 我在这里使用LINQPad ,但唯一的区别是你如何掌握应用程序):
Selection
Window
var vApp = MyExtensions.GetRunningVisio(); var firstComponent = (short)Visio.VisSectionIndices.visSectionFirstComponent; foreach (Visio.Shape shp in vApp.ActiveWindow.Selection) { for (short s = firstComponent; s < firstComponent + shp.GeometryCount; s++) { var geoSection = shp.Section[s]; for (short r = 1; r < geoSection.Count; r++) { var rt = shp.RowType[s, r]; Enum.GetName(typeof(Visio.VisRowTags), rt).Dump(); //You now have the shape, section and row and, if you want to, //you can get to cells by using CellsSRC syntax: //var someCellValue = shp.CellsSRC[s, r, (short)Visio.VisCellIndices.visX].ResultIU; //How you address the cell will depend on the row type that you're targeting. } } }
如果您使用它进行导出,那么您可能还希望将文档保存为SVG。以下是一些选项:
另一种选择可能是看看 路径 / PathsLocal 形状的属性。例如,在foreach形状内:
for (int x = 1; x <= shp.Paths.Count; x++) { Visio.Path p = shp.PathsLocal[x] as Visio.Path; p.Points(0.1, out Array pntsArr); pntsArr.Dump(); }