Attribute Assistant

From Wildsong
Jump to navigationJump to search

Attribute Assistant is an add-in for ESRI ArcMap. It is pretty neat.

I have deployed it to help our cartographers with maintenance of tax lots. It will populate much of the attribute data for them.

The version I am using was release January 2018

Official documentation

This is the best description I have found so far: https://solutions.arcgis.com/state-government/help/sign-inventory/tools/tour-attribute-assistant/

My 2 cents

The good parts

  • They are still releasing new versions (so far) and it's supported.
  • The range of built in functions is pretty good.
  • The documentation is reasonably good.
  • There is a logging debug option. Turn it on in the config.

The awful part -- VBScript

Expressions have to be written in VBScript, which is like stepping back in time about 15 years for me. I stopped using VBScript when ESRI started supporting Python and (until today) I never looked back.

Python is clean, expressive, and consistent in its approach. It has been adopted widely, so you only have to learn one language to accomplish everything from GIS to Web apps to sysadmin.

I need a link here to the VBScript guide. Don't be confused by references to Visual Basic or VB.Net. I am not sure about the browser version of VBScript, so take this VBScript reference at w3schools with a grain of salt. Also perhaps this tutorial. Maybe they are great; they helped me today.

Concatenate strings with "&"

You can use VBScript in label expressions for testing

Comment out strings with "rem"

Use () as array element delimiters instead of [].

The stupid part

The word is that ESRI now wants me to learn and use "Arcade" which is not Python and not Javascript. I am delaying in the hopes that it goes away before I have to learn it.

James Fee's comments on Arcade https://medium.com/@jamesfee/esri-arcade-3b6515d08d28

I say Arcade is stupid because I feel coerced to learn Arcade and no one likes being coerced by a vendor. I embraced Python because I knew skills learned there would be portable. In 5 years (tops) ESRI will announce it no longer supports Arcade.

Tricks and pratfalls

In case you have not looked at it yet, the way it works is that you put a table in your MXD called DynamicValue and then populate it with rules. The add-in fires the rules when the events are tripped.

A trick: populate the AutoWho and AutoDate attributes

Table Name Field Name Value Method Value Info On Create On Change (Attribute) On Change (Geometry) Manual Only Rule Weight Comments
* AutoWho CURRENT_USER U 1 1 1 0 <Null>
* AutoDate TIMESTAMP DATE 1 1 1 0 <Null>

AutoWho: Putting U in the Value Info column makes it use only the user name, otherwise it puts DOMAIN\USERNAME which is ugly.

AutoDate: Putting DATE in the Value Info column makes it use only the date, no time stamp, which is what I want.

Pratfall category

Table Name Field Name Value Method Value Info On Create On Change (Attribute) On Change (Geometry) Manual Only Rule Weight Comments
taxlot MapTaxlot EXPRESSION Split( [MapNumber],".")(0)&Split( [MapNumber],".")(1)&" "&Split( [MapNumber],".")(2)&" "& [Taxlot] 1 1 1 0 <Null>

When using expressions, you have to cram your VBScript into the Value Info field, no matter how long or complex. It has to be on one line since there is no support for anything like a code block. Expressions can be complex, and support IF statements, but they will be hard to support.

So in this case I had to call "Split" 3 times with the same arguments. Normally I'd say that's awful and it would be two lines, but I don't see any way to do that in Attribute Assistant. In ArcMap I'd use a code block.

s = Split([MapNumber],".")
s(0)&s(1)&" "&s(2)&" "& [Taxlot]

There are currently 68 built in functions in the Assistant and EXPRESSION is just one of them. Use the other 67 if you can!

What is "Rule weight"?

"Rank rules in order of priority. Rules with a higher weight are processed first. Rules with null values are always run last."

That's what I guessed. So for example in my case, so far I have not needed it but if I wanted to cascade several attributes, then I'd need to control execution order.

Debugging

No errors pop up when you have problems in your DynamicValue table. You have to enable the debug log in the config file, then restart ArcMap, then check the log file for things like this:

Expression to be eval: CInt(Mid("",9,2))
                 ERROR: evaluating the expression for feature in Taxlots with OID of 2202
                        System.Runtime.InteropServices.COMException (0x800A000D): Type mismatch: 'CInt'

CInt is supposed to convert the string to a short. Town,Range,SecNumber are shorts. Qtr, QtrQtr are Char[1] So the output type should be ok.

I get type mismatch errors in the ArcMap Label Expression "Verify" with

Function FindLabel ( [TownDir] )
 i = CInt("")
 FindLabel = CStr(i)
End Function

That means the input is probably non-numeric. I wonder how I fix that! Maybe I can add a leading zero. That deals with empty strings, assuming Mid does not freak out..

Function FindLabel ( [TownDir] )
 i = CInt("0" & Mid("", 8,1))
 FindLabel = CStr(i)
End Function

..works! Returns 0. I changed the rules in DynamicValue and that error is fixed.

This is the one that's really giving me trouble, from the debug log. I wonder about "Searching the layer"; is it searching the right layer? Does it find anything? (I also wonder why I am not seeing ORMapNum calculated. Ah, typo, I had Table Name = "axlots", oops.)

     Row Info
       Row Number 1
       TableName: taxlots
       FieldName: MapNumber
       ValueInfo: mapindex|MapNumber|10
       ValueMethod: NEAREST_FEATURE
       On Create: 1
       On Change: 0
     Checking for Subtype Restriction
     Field Name: MapNumber was found at index: 14
                 Trying: NEAREST_FEATURE
                 Searching the layer
                 Finished: NEAREST_FEATURE

I was using a layer that had a DDP page definition on it.