Visio:如何获取包含在一个形状中的形状? [英] Visio: How to get the shapes that are contained in one shape?

查看:94
本文介绍了Visio:如何获取包含在一个形状中的形状?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法从包装(扩展)"形状中获取SpartialNeighbors方法的信息.

通常我使用以下代码:

 将Dim s作为形状,将vsoShapeOnPage作为形状Visio.Selection中的Dim vsoReturnedSelection包含当前形状设置vsoReturnedSelection = s.SpatialNeighbors(visSpatialContain,0,visSpatialIncludeContainerShapes)如果vsoReturnedSelection.Count = 0则'不包含任何形状别的对于vsoReturnedSelection中的每个vsoShapeOnPage'代码下一个万一 

这对于默认的UML模具(nameU ="Overview")中的形状来说效果很好

我知道我可以对形状进行分组,但这会增加工作量.

另一点,当我分析其他形状时,在"MemberOfContainers"中看到该形状包含在包装(展开)"中.因此,必须有可能从另一种方式获得信息而无需经历所有形式.

在这里您可以看到包装"和界面"的形状

解决方案

如果形状是容器,则它是

您可以像这样握住成员形状:

  Sub CheckMyPackageContainer()'假定在活动图形窗口中选择了容器形状调用ReportContainerShape(ActiveWindow.Selection.PrimaryItem)结束子子ReportContainerShape(ByRef contShp作为Visio.Shape)如果没有contShp什么都没有,那么昏暗的containerProps作为ContainerProperties设置containerProps = contShp.ContainerProperties如果没有containerProps则什么也没有只要Dim lngContainerMembers()lngContainerMembers = containerProps.GetMemberShapes(Visio.VisContainerFlags.visContainerFlagsDefault)Dim HostingPage作为Visio.Page设置hostingPage = contShp.ContainingPage对于lngContainerMembers中的每个varMemberDim shpItem作为Visio.Shape设置shpItem = HostingPage.Shapes.ItemFromID(varMember)Debug.Print shpItem.NameU,"Text ="&shpItem.Text下一个万一万一结束子 

这将导致以下输出(注意不包括"InterfaceThree"):

 接口文本= InterfaceOneInterface.30文字= InterfaceTwo 

I cannot get the information of the method SpartialNeighbors out of a "Package (expanded)" shape.

Normally I use this code:

 Dim s As Shape, vsoShapeOnPage As Shape
 Dim vsoReturnedSelection As Visio.Selection  

 's contains the current shape
 Set vsoReturnedSelection = s.SpatialNeighbors(visSpatialContain, 0, visSpatialIncludeContainerShapes)
        If vsoReturnedSelection.Count = 0 Then
            'No Shapes contained
        Else
            For Each vsoShapeOnPage In vsoReturnedSelection
               'Code
            Next
        End If

And this works perfectly fine for shapes like in the default UML stencil (nameU = "Overview")

I know I could group the shapes, but it increases the effort.

Another point, when I analyse other shapes I see with "MemberOfContainers" that the shape is contained in "Package (expanded)". So it must be possible to get the information from the other way around without going through all shapes.

Here you can see the "Package" and shapes of "interface"

解决方案

If a shape is a container, it's ContainerProperties property will be populated (ie not null). You can then interogate that to retrieve an array of member shape IDs.

The following is a slightly adapted version of some sample code found in the SDK download - based on a document looking like this:

You can get hold of the member shapes like this:

Sub CheckMyPackageContainer()
    'Assumes container is selected shape in active drawing window
    Call ReportContainerShape(ActiveWindow.Selection.PrimaryItem)
End Sub


Sub ReportContainerShape(ByRef contShp As Visio.Shape)
    If Not contShp Is Nothing Then
        Dim containerProps As ContainerProperties
        Set containerProps = contShp.ContainerProperties
        If Not containerProps Is Nothing Then
            Dim lngContainerMembers() As Long
            lngContainerMembers = containerProps.GetMemberShapes(Visio.VisContainerFlags.visContainerFlagsDefault)

            Dim hostingPage As Visio.Page
            Set hostingPage = contShp.ContainingPage
            For Each varMember In lngContainerMembers
                Dim shpItem As Visio.Shape
                Set shpItem = hostingPage.Shapes.ItemFromID(varMember)
                Debug.Print shpItem.NameU, "Text = " & shpItem.Text
            Next
        End If
    End If
End Sub

This will result in the following output (noting that 'InterfaceThree' is not included):

Interface     Text = InterfaceOne
Interface.30  Text = InterfaceTwo

这篇关于Visio:如何获取包含在一个形状中的形状?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆