VBA: List SDE Layers With Metadata Source

Written by AGRC Administrator,

This script works on a selected set of SDE feature datasets and feature classes within ArcCatalog.

It reports the layers and their 'source' as identified in the metadata citation section 

Public Sub listallwithsource()
    Open "C:\temp\sgidtest\listall.txt" For Output As #2
    Dim pGxApp As IGxApplication
    Dim pSelGxObject As IGxObject
    Dim pGxSel As IGxSelection
    Dim pEnumGxObjSel As IEnumGxObject
    Dim pGxDataset As IGxDataset
    Dim pMetadata As IMetadata
    Dim pPropertySet As IPropertySet
    
    Dim pGxObjContainer As IGxObjectContainer
    Dim pEnumGxObj As IEnumGxObject
    Dim pCurrGxObject As IGxObject
    
    Dim vName As String
    Dim vValue As Variant
    Dim V As Variant
    
    Set pGxApp = Application
    Set pGxSel = pGxApp.Selection
    Set pEnumGxObjSel = pGxSel.SelectedObjects
    pEnumGxObjSel.Reset
    Set pSelGxObject = pEnumGxObjSel.Next
    Dim fccnt As Long
    Do Until pSelGxObject Is Nothing
        If pSelGxObject.Category = "SDE Feature Class" Then
            fccnt = fccnt + 1
            Debug.Print "  .. " & pSelGxObject.BaseName
            Print #2, "  .. " & pSelGxObject.BaseName
        ElseIf pSelGxObject.Category = "SDE Feature Dataset" Then
            
            Debug.Print pSelGxObject.BaseName & " (FDS)"
            Print #2, ""
            Print #2, pSelGxObject.BaseName & " (Category)"
            
            
            Set pGxObjContainer = pSelGxObject
            If pGxObjContainer.HasChildren Then
                Set pEnumGxObj = pGxObjContainer.Children
                If Not pEnumGxObj Is Nothing Then
                    Set pCurrGxObject = pEnumGxObj.Next
                    Do Until pCurrGxObject Is Nothing
                        If pCurrGxObject.Category = "SDE Feature Class" Then
                            fccnt = fccnt + 1
                            If TypeOf pCurrGxObject Is IGxDataset Then
                                Set pGxDataset = pCurrGxObject
                            
                                Set pMetadata = pGxDataset 'QI
                                Set pPropertySet = pMetadata.Metadata

                                vName = "idinfo/citation/citeinfo/origin"
                                vValue = pPropertySet.GetProperty(vName)
                                Dim sstr As String
                                sstr = ""
                                
                                If Not IsEmpty(vValue) Then
                                    For Each V In vValue
                                        sstr = sstr & CVar(V) & " "
                                        
                                    Next
    
                                    If InStr(sstr, "REQUIRED") > 0 Then
                                        sstr = ""
                                    End If
                                End If
                                
                                
                                Debug.Print "  .. " & pCurrGxObject.BaseName & " (src: " & sstr & ")"
                                Print #2, "  .. " & pCurrGxObject.BaseName & " (src: " & sstr & ")"
                            End If
                        End If
                        Set pCurrGxObject = pEnumGxObj.Next
                    Loop
                End If
            End If
        End If
        Set pSelGxObject = pEnumGxObjSel.Next
    Loop
    Close #2
End Sub

Users' Comments  
 

No comment posted

Add your comment

01, May. 2008