You are here

Useful Scripts for the Non-Programmer: Where is My AU Configured?

– Corey Blakeborough

ArcFM Autoupdaters are incredibly useful and widely used. Unfortunately, it can be difficult to keep track of them. There are many different potential reasons behind a need to find out where a specific AU is configured.

Today, we’re going to hand over an ArcCatalog VBA script that allows you to see the feature classes, subtypes, and events that any AU is assigned to. Simply run the script while selecting an open connection in ArcCatalog, input the display name of the AU in question, and you’ll be given a list of every location where that AU is configured.

NOTE: This script does not work for field-level autoupdaters or relationship autoupdaters, only for autoupdaters at the feature class level, though those scripts may appear in the future!

We should quickly mention that we’re matching the AU based on display name, so if you don’t know that by heart, you’ll need to know at least one location where the AU is configured to get the display name from the feature class’ ArcFM Properties window (alternatively, if you wrote the AU and have the code, you probably put it there too). An example is below:

useful-scripts-get-au-display-name

So here’s how we can make this work:

  • Open ArcCatalog.

  • Drop down the Tools menu and choose MacrosVisual Basic Editor.useful-scripts-vb-editor

  • Within the Visual Basic environment, expand the Normal.mxt file. Right-click it and insert a new Module within the Modules folder.

  • In the editor, click Tools → References and ensure that the following references are enabled:
    • Microsoft Scripting Runtime
    • Miner & Miner Geodatabase Object Library
    • Miner & Miner System Object Library

 useful-scripts-enable-microsoft-scripting-runtime

The code for this module is below, and it’s long! Copy and paste it into the module and save it.


Dim m_returnValues() As String
Dim
searchAUName As String
Dim
ac As Integer

Public Sub
FindConfiguredAUs()
    On Error GoTo EX

    ac = 0
    searchAUName = ""
    ReDim m_returnValues(0)

    Dim catalogApp As IGxApplication
    Set catalogApp = Application
    Dim ws As IWorkspace

    If TypeOf
catalogApp.SelectedObject Is IGxDatabase Then
        Dim
gdb As IGxDatabase
        Set gdb = catalogApp.SelectedObject
        If gdb.IsConnected Then
            Set
ws = gdb.Workspace
        End If
    End If

    If
ws Is Nothing Then
        ShowError "Please select a database connection to search for when running this function."
        Exit Sub
    End If


    searchAUName = InputBox("Enter the AU Display Name to search for:", "Find Autoupdater by Name")

    If Not searchAUName = "" Then
        Dim
eDS As IEnumDataset
        Set eDS = ws.Datasets(esriDatasetType.esriDTAny)
        IterateDatasets eDS

        Dim sb, i As Integer
        sb = "The '" & searchAUName & "' AU is configured in the following locations/subtypes:" & vbCrLf
        For i = 0 To UBound(m_returnValues)
            sb = sb & m_returnValues(i) & vbCrLf
        Next i

        Dim AUResultsFile As String
        AUResultsFile = "C:\Temp\AUResults" & DatePart("yyyy", Now) & "-" & Right("0" & DatePart("m", Now), 2) & "-" & Right("0" & DatePart("d", Now), 2) & " " & Right("0" & DatePart("h", Now), 2) & Right("0" & DatePart("n", Now), 2) & ".txt"

        Dim fso As Scripting.FileSystemObject
        Set fso = New Scripting.FileSystemObject
        Dim writer As TextStream
        Set writer = fso.CreateTextFile(AUResultsFile, True)
        writer.Write sb
        Shell "notepad.exe " & AUResultsFile, vbMaximizedFocus
        writer.Close
        Debug.Print sb
        fso.DeleteFile AUResultsFile, True
    End If
    Exit Sub

EX: ShowError "An error occured."
End Sub

Sub
IterateDatasets(pEnumDataset As IEnumDataset)
    Dim ds As IDataset

    pEnumDataset.Reset
    Set ds = pEnumDataset.Next
    Do While Not ds Is Nothing
        If
ds.Type = esriDatasetType.esriDTFeatureClass Then
            Dim
dfc As IFeatureClass
            Set
dfc = ds
            ProcessFeatureClass dfc
        ElseIf ds.Type = esriDatasetType.esriDTFeatureDataset Then
            IterateDatasets ds.Subsets
        End If
        Set
ds = pEnumDataset.Next
    Loop
End Sub

Sub
ProcessFeatureClass(fc As IFeatureClass)
    If Not fc Is Nothing Then
        Dim
desc As String
            Dim
code As Long
            desc = ""

            Dim oc As IObjectClass
            Set oc = fc

        Dim enSt As IEnumSubtype
        Dim ocSt As ISubtypes

        Set ocSt = oc
        Set enSt = ocSt.Subtypes

        desc = enSt.Next(code)
        Do While Not desc = ""
            Dim ctl As IMMConfigTopLevel
            Set ctl = New MMConfigTopLevel

            Dim mmSubtype As IMMSubtype
            Dim list As ID8List
            Dim listItem As ID8ListItem

            Set mmSubtype = ctl.GetSubtypeForEdit(oc, code)
            Set list = mmSubtype

            list.Reset
            Set listItem = list.Next(False)
            Do While Not listItem Is Nothing
                If
listItem.ItemType = mmd8ItemType.mmitAutoValue Then
                    Dim
autoValue As IMMAutoValue
                    Set autoValue = listItem
                    If Not autoValue.autoGenID Is Nothing Then
                        Dim
UIDT As IMMUIDTools
                        Set UIDT = New MMUIDTools

                        Dim createdObject As Variant
                        Dim
auName As String

                        Dim
pAutoGenID As String
                        pAutoGenID = autoValue.autoGenID

                        Set createdObject = UIDT.CreateFromClsidString(pAutoGenID)
                        auName = ""

                        If TypeOf createdObject Is IMMSpecialAUStrategy Then
                            Dim
au1 As IMMSpecialAUStrategy
                            Set au1 = createdObject
                            auName = au1.Name
                        ElseIf TypeOf createdObject Is IMMSpecialAUStrategyEx Then
                            Dim
au2 As IMMSpecialAUStrategyEx
                            Set au2 = createdObject
                            auName = au2.Name
                        ElseIf TypeOf createdObject Is IMMAttrAUStrategy Then
                            Dim
au3 As IMMAttrAUStrategy
                            Set au3 = createdObject
                            auName = au3.Name
                        End If

                        If
(Not auName = "") And LCase(Trim(auName)) = LCase(Trim(searchAUName)) Then
                            ReDim Preserve
m_returnValues(ac + 1)
                            Dim sc As String
                            sc = mmSubtype.SubtypeCode
                            m_returnValues(ac) = oc.AliasName & " (" & sc + ") " & listItem.DisplayName
                            ac = ac + 1
                        End If
                    End If
                End If
                Set
listItem = list.Next(False)
            Loop
            desc = enSt.Next(code)
        Loop
    End If
End Sub

Sub
ShowError(msg As String)
    MsgBox msg, vbOKOnly, "SSP Find Configured AUs"
End Sub


When running the script, be sure that you have a connection open and you’ve selected it (it should be highlighted in ArcCatalog):

useful-scripts-ensure-open-connection

After that, you’ll have a nice list of every combination of feature class, subtype, and event for that AU.

useful-scripts-au-results

Add new comment

Filtered HTML

  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <!-->
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Type the characters you see in this picture. (verify using audio)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.