Modifying existing VST and label expressions to abbreviate annotation (Aviation)

The abbreviate shortcut menu allows you to choose an abbreviation option for the selected piece of annotation while in an edit session.


It is assumed that you have existing LXP and VST expressions and are knowledgeable about the creation of these expressions. See Creating annotation with an advanced callout and multiple text elements to create LXP or VST expressions.

This annotation abbreviation code uses two nested arrays to create a string that is stored in the database, then the label expression splits the two nested arrays out of the string to create the annotation display. The LabelStatus_Code field, with a coded value domain, is used to store the abbreviation option chosen for each annotation feature. This field must have a data type of Text with a length of at least 2,000 characters. If you are exceeding the 2,000 character limit, see Code example: VST with duplicate array values removed.

Modifying the original VST expression

You can edit your existing VST expression and save it as a new copy that will become your new LXP.

  1. Open your existing VST expression in WordPad and save a copy.

    Visual Studio may also be used for editing and debugging.

  2. In your existing VST, keep the first Function Generate line and delete the rest of the code.

    Delete all code below this:

    Function Generate([OBJECTID], [OBJECTID_arr], [LABELSTATUS_CODE], [LABELSTATUS_CODE_arr], [PRIMARYNAVAID_CODE], [PRIMARYNAVAID_CODE_arr], [SystemSubtype], [SystemSubtype_arr], [Ident_Txt], [Ident_Txt_arr], [Frequency_Val], [Frequency_Val_arr], [Channel_Txt], [Channel_Txt_arr], [Voice_Code], [Voice_Code_arr], [ComponentSubtype], [ComponentSubtype_arr], [Name_Txt], [Name_Txt_arr], [LAT_TXT], [LAT_TXT_arr], [LONG_TXT], [LONG_TXT_arr], [ROLEFIX_CODE], [ROLEFIX_CODE_arr])
  3. Paste the following code below the Function Generate line:

    Add the *_arr field names from the Function Generate list within the parentheses of the Array() on the next line.

    VariableArray = Array() 
    k = 0 do while k < UBound(VariableArray) + 1 
                   tempArray = VariableArray(k) 
                   i = 1
                   outputText = outputText & tempArray(0) 
                   do while i < ubound(tempArray) + 1 
                   outputText = outputText & "<>"
                   outputText = outputText & tempArray(i) 
                   i = i + 1 
    outputText = outputText & "||" 
          k = k + 1 
    Generate = outputText 
    End Function
  4. Add only the *_arr field names from the Function Generate list to the Array list.

    See the comment in the code above for placement.

    For example: Array([OBJECTID_arr], [LABELSTATUS_CODE_arr] ], [PRIMARYNAVAID_CODE_arr])

    This step completes your VST expression edits. It should now be similar to Code example: New VST expression. Follow the next section to modify your LXP.

Modify the label expression

  1. Open your new LXP in Wordpad.
  2. Remove any non-array field names and all square brackets [ ] surrounding field names.

    You can use Find > Replace All.

  3. Paste the following code above the Function Generate line:

    In this example, IAPNAVAID_LBL is the field VST uses, and LABELSTATUS_CODE is the coded domain field annotation abbreviation uses.

    Function FindLabel ( [IAPNAVAID_LBL], [LABELSTATUS_CODE] )
    ValueArray = Split([IAPNAVAID_LBL], "||") 
    OBJECTID= ValueArray(0)
    OBJECTID_arr= Split(OBJECTID ,"<>") 
    PRIMARYNAVAID_CODE= ValueArray(2) 
              PRIMARYNAVAID_CODE_arr= Split(" " ,"<>") 
    end if 
    SystemSubtype= ValueArray(3) 
    SystemSubtype_arr= Split(SystemSubtype ,"<>") 
    Ident_Txt= ValueArray(4)
    Ident_Txt_arr= Split(Ident_Txt ,"<>") 
    Frequency_Val= ValueArray(5) 
    Frequency_Val_arr= Split( Frequency_Val,"<>")
    Channel_Txt= ValueArray(6) 
    Channel_Txt_arr= Split( Channel_Txt,"<>") 
    Voice_Code= ValueArray(7) 
    Voice_Code_arr= Split(Voice_Code ,"<>") 
    ComponentSubtype= ValueArray(8)
    ComponentSubtype_arr= Split( ComponentSubtype,"<>") 
    Name_Txt= ValueArray(9) 
    Name_Txt_arr= Split(Name_Txt ,"<>") 
    LAT_TXT= ValueArray(10) 
    LAT_TXT_arr= Split(LAT_TXT ,"<>") 
    LONG_TXT= ValueArray(11) 
    LONG_TXT_arr= Split(LONG_TXT ,"<>")
    ROLEFIX_CODE= ValueArray(12) 
    ROLEFIX_CODE_arr= Split(ROLEFIX_CODE ,"<>")

    The ValueArray(*) listed above should match the order of the fields in the Variable Array of the VST expression (step 3). In the code above, the value of zero is used for the ValueArray of OBJECTID because it is the first field in the Variable Array list of the VST expression:

    OBJECTID= ValueArray(0)
  4. Remove the original Function Generate code that is now below the code you pasted in step 3.

    Delete the following code:

    Function Generate([OBJECTID], [OBJECTID_arr], [LABELSTATUS_CODE], [LABELSTATUS_CODE_arr], [PRIMARYNAVAID_CODE], [PRIMARYNAVAID_CODE_arr], [SystemSubtype], [SystemSubtype_arr], [Ident_Txt], [Ident_Txt_arr], [Frequency_Val], [Frequency_Val_arr], [Channel_Txt], [Channel_Txt_arr], [Voice_Code], [Voice_Code_arr], [ComponentSubtype], [ComponentSubtype_arr], [Name_Txt], [Name_Txt_arr], [LAT_TXT], [LAT_TXT_arr], [LONG_TXT], [LONG_TXT_arr], [ROLEFIX_CODE], [ROLEFIX_CODE_arr])
  5. Below the code you just pasted, replace the Generate = "<MultipleTextElement>" with FindLabel = "<MultipleTextElement>" to specify the FindLabel function output.
  6. Compare the order of arrays in the new LXP Function FindLabel to those in the new VST Array creation and make sure they are in the same order.
  7. Ensure that there is a coded value and abbreviation description for LabelStatus_Code.

    For example: If LABELSTATUS_CODE_arr(0) = "1" OR LABELSTATUS_CODE_arr(0) = "Abbreviate IAF" Then TopTextElement = ""


    The coded value descriptions are determined by the coded domain you created in your database.

  8. Save your new LXP as an .lxp file.

Setting the new VST expression

The new VST expression can replace the existing expression.

  1. Start ArcMap.
  2. Right-click the feature class to which you want to apply the VST expression and click Properties.
  3. Click the Calculated Fields tab.
  4. Click the SQL Statement drop-down arrow and click Edit SQL statement.
  5. Check the Edit query text check box.

    The SELECT, FROM, and WHERE text boxes become editable.

  6. Paste the VST expression you just created into the Query Builder dialog box.
  7. Uncheck the Edit query text check box when you are finished editing the statement.
  8. 单击确定
  9. Ensure that the Update Feature Class(es) check box is checked.
  10. 单击确定
  11. End the ArcMap session.

Loading the new LXP

The new LXP must be applied to be able to abbreviate annotation.

  1. Start ArcCatalog.
  2. Browse to the annotation feature class you want to abbreviate.
  3. Right-click the annotation feature class and choose Properties.
  4. Click the Annotation Classes tab.
  5. Click the Expression button.
  6. Click Load and browse to the LXP file.

    You may have to copy and paste from Wordpad.

  7. 单击打开
  8. Click OK twice.

You are now ready to edit annotation and use the abbreviation options.