在Visio中识别形状父对象 [英] Identifying a shape parent in visio
问题描述
我有一个visio文档,它是BPMN模板.在BPMN文档中,我通过选择 Moreshapes-> 放置了BPMN形状以及Engineering,FLowChart,Networking,Basic形状等其他形状. >
Hii i have a visio document which is an BPMN template .In that BPMN document i have placed a BPMN shape and also other shapes from Engineering,FLowChart,Networking,Basic shapes etc by choosing Moreshapes->
所以我的BPMN visio文档如下所示
and so my BPMN visio document looks like below
因为BPMN和Task命名为BPMN形状,计算机是网络->计算机的形状,矩形来自常规->基本形状,就像其他形状一样还 . (即)在BPMN visio文档中,具有BPMN形状的i也具有其他形状.
in that BPMN and Task named are a BPMN shapes,Computer is a shape from Network->Computer ,Rectangle is from General->BasicShapes like that the other shape also . (ie) In a BPMN visio document , with the BPMN shape i have the other shapes also.
如何在c#.. ???中识别形状父级
How to identify the shape parent in c#..???
例如: BPMN命名为shape是来自BPMN的形状. 名为shape的任务是来自BPMN的shape. 名为shape的计算机是Network中的shape. 矩形是来自通用的形状.
eg: BPMN named shape is shape from BPMN. Task named shape is shape from BPMN. computer named shape is shape from Network. Rectangle named shape is shape from General.
推荐答案
我必须承认,这比我预期的要困难得多.模具实际上位于文档集合中,它们不包含形状,仅包含母版.无论如何:这是您如何为活动图形的每种形状获取父模具名称的方法:
I must admit, this is more difficult than I would have expected. The stencils are actually in the documents collection and they do not contain shapes, only masters. Anyway: this is how you get the parent stencil name for each shape of your active drawing:
using Visio = Microsoft.Office.Interop.Visio;
var visio = (Visio.Application) System.Runtime.InteropServices.Marshal.GetActiveObject("Visio.Application");
var vsd = visio.ActiveDocument;
foreach(Visio.Shape shape in vsd.Pages[1].Shapes) {
foreach(Visio.Document stencil in visio.Documents) {
if (stencil.Type == Visio.VisDocumentTypes.visTypeStencil) {
foreach(Visio.Master sh in stencil.Masters) {
if (sh.Name == shape.Name) {
Console.WriteLine(stencil.Name);
break;
}
}
}
}
}
这篇关于在Visio中识别形状父对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!