2017-02-15 11 views
0

"패키지 (확장)"모양에서 SpartialNeighbors 메서드 정보를 가져올 수 없습니다.Visio : 한 모양에 포함 된 모양을 얻는 방법?

는 일반적으로이 코드를 사용 :

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 

을 그리고 이것은 (nameU = "개요")

은 내가 그룹 모양 할 수 알지만, 기본 UML 스텐실처럼 모양을 위해 완벽하게 잘 작동 그것은 노력을 증가시킵니다.

또 다른 요점은 "MemberOfContainers"에서 볼 수있는 다른 모양을 분석 할 때 모양이 "Package (expanded)"에 포함되어 있다는 것입니다. 따라서 모든 모양을 거치지 않고 다른 방향에서 정보를 얻을 수 있어야합니다. 모양이 컨테이너의 경우

다음은 "패키지"및 "인터페이스" Extract of the diagram

답변

1

의 모양을 볼 수 있습니다, 그것은 ContainerProperties 속성 (즉, null가 아닌) 채워집니다입니다. 그런 다음이를 인터리빙하여 구성원 셰이프 ID의 배열을 검색 할 수 있습니다.

다음은 SDK 다운로드에서 발견 된 일부 샘플 코드의 약간 적응 버전입니다 다음 -이처럼 보이는 문서를 기반으로 :

Visio Container Shapes

당신은이 같은 멤버 모양의 보류를 얻을 수 있습니다 :

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 

이것은 다음 출력 될 것이다 ('InterfaceThree'가 포함되어 있지 않은 것을 주목)

Interface  Text = InterfaceOne 
Interface.30 Text = InterfaceTwo