Modifying existing VST and label expressions to abbreviate annotation
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.
-
Open your existing VST expression in Wordpad and save a copy.
Remarque :
Visual Studio may also be used for editing and debugging.
- 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])
- 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 loop outputText = outputText & "||" k = k + 1 loop Generate = outputText End Function
- 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
- Open your new LXP in Wordpad.
- Remove any nonarray field names and all square brackets [ ]
surrounding field names.Conseil :
You can use Find > Replace All.
- 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], "||") LABELSTATUS_CODE_arr = Split( [LABELSTATUS_CODE] ,"<>") OBJECTID= ValueArray(0) OBJECTID_arr= Split(OBJECTID ,"<>") PRIMARYNAVAID_CODE= ValueArray(2) if IsNull(PRIMARYNAVAID_CODE) or PRIMARYNAVAID_CODE = "" Then PRIMARYNAVAID_CODE_arr= Split(" " ,"<>") else PRIMARYNAVAID_CODE_arr= Split(PRIMARYNAVAID_CODE ,"<>") 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 ,"<>")
Remarque :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)
- 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])
- Below the code you just pasted, replace the Generate = "<MultipleTextElement>" with FindLabel = "<MultipleTextElement>" to specify the FindLabel function output.
- 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.
- 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 = ""
Remarque :The coded value descriptions are determined by the coded domain you created in your database.
- Save your new LXP as an .lxp file.
Setting the new VST expression
The new VST expression can replace the existing expression.
- Start ArcMap.Conseil :
If the ArcMap - Getting Started dialog box appears, you can open a new or existing map document. You can also check the Do not show this dialog box in the future check box and click Open.
- Right-click the feature class to which you want to apply the VST expression and click Properties.
- Click the Calculated Fields tab.
- Click the SQL Statement drop-down arrow and click Edit SQL statement.
-
Check the Edit query text check box.
The SELECT, FROM, and WHERE text boxes become editable.
- Paste the VST expression you just created into the Query Builder dialog box.
- Uncheck the Edit query text check box when you are finished editing the statement.
- Click OK.
- Ensure that the Update Feature Class(es) check box is checked.
- Click OK.
- End the ArcMap session.
Loading the new LXP
The new LXP must be applied to be able to abbreviate annotation.
- Start ArcCatalog.
- Browse to the annotation feature class you want to abbreviate.
- Right-click the annotation feature class and choose Properties.
- Click the Annotation Classes tab.
- Click the Expression button.
- Click Load and browse to the LXP file.Conseil :
You may have to copy and paste from Wordpad.
- Click Open.
- Click OK twice.
You are now ready to edit annotation and use the abbreviation options.