POST
|
I am using a SQL Server SDE database to periodically refresh a feature class that is the parent for feature-linked annotation created in ArcMap 10.7.1. Existing labels can be refreshed by editing a field in the parent feature class used by the label expression (do a field calculation on a column that sets it equal to itself to refresh all labels at once). The problem is that the presence new records (locations) in the parent do not trigger generation of new annotation, apparently because the new records have been added outside of the ArcGIS geodatabase structure. (In contrast, creating or pasting locations in ArcMap does trigger annotation creation.) Editing a field used by the label expression has no effect. Copying and pasting the new records triggers label generation for the pasted copies, but the new copies have object IDs assigned by ArcMap and thus will differ from the object IDs assigned to those locations in future refreshes, which will break the relationship with the newly generated annotation. Is there another way to trigger the generation process, perhaps pythonically via an arcpy function?
... View more
08-18-2020
05:15 PM
|
0
|
1
|
438
|
POST
|
Digging deeper, there appears to be a problem initializing lists in Python at runtime in feature-linked annotation. For me, the following code updates the annotation text string: def FindLabel ([SampleID],[Benzoaanthracene]): aNames = "Benzo(a)anthracene" SampleIDLocal = str([SampleID]) TheLabel = SampleIDLocal + ' ' + aNames + ' = ' + str([Benzoaanthracene]) return TheLabel Whereas initializing aNames as an empty list results in static annotation: def FindLabel ([SampleID],[Benzoaanthracene]): aNames = [] SampleIDLocal = str([SampleID]) TheLabel = SampleIDLocal + ' Benzo(a)anthracene = ' + str([Benzoaanthracene]) return TheLabel Even stranger, when I commented out the offending line (#aNames = []), annotation was still static. On the off chance that aNames is somehow a reserved word, I changed it to arrayNames (still static) and then gibberish (alkghowish, which worked!). Changing to aDspNam = [] also worked until I actually tried to populate the list. Given this unpredictable behavior, I am going to return to using VBA for label expressions.
... View more
09-19-2019
06:22 PM
|
0
|
0
|
1364
|
POST
|
The run-time environment for label expressions in feature-linked annotation seems to be slightly different than in feature-class labels such that the label expression may crash and fail to update the annotation text string, whereas it runs just fine in a feature-class label. I discovered this behavior when annotation from my latest label expression did not update, whereas an earlier version worked as advertised by ESRI. The latest version is in Python rather than VBA, and I probably did something questionable during translation from the earlier version. It's not just a Python thing; I made simple label expressions in both Python and VBA, and feature-linked annotation based on each exhibited the expected on-the-fly updating. Regarding the original poster's problem, I suspect that data-type coercion in the two environments is not identical for Python, and the solution may be to explicitly convert all parameters to UTF-8 strings before doing anything else with them.
... View more
09-19-2019
03:24 PM
|
0
|
1
|
1364
|
Online Status |
Offline
|
Date Last Visited |
06-28-2023
11:27 PM
|