AnnotationFeature example + data anywhere?

1204
3
Jump to solution
01-13-2021 05:25 AM
PetrDiviš
New Contributor III

Hello,

I'm trying to go through layers in projects and I have an imported project from ArcMap with annotations and I'm trying to get the AnnotationFeature from AnnotationLayer that has AnnotationSubLayers, but i keep getting Feature object.

 

Does anyone have a valid code and data example?

 

Thank you!

 

Here is what I have and something is wrong:

 

 

//this finds 3 Annotations in view extent (I can see in GUI it has same TextString, different AnnotationClassId,SymbolID)
SpatialQueryFilter qf = new SpatialQueryFilter();
qf.FilterGeometry = viewExtentGeometry;
qf.SpatialRelationship = SpatialRelationship.Intersects;

...

if (_lyr is AnnotationLayer alr)
  return ConsumeCursorAnnotation(alr.Search(qf));

...

/// this returns null when casted to AnnotationFeature
private IEnumerable<AnnotationFeature> ConsumeCursorAnnotation(RowCursor featureCursor)
{
     while (featureCursor.MoveNext())
       yield return featureCursor.Current as AnnotationFeature;
}

 

 

 

PetrDiviš_1-1610544112819.png

 

 

0 Kudos
1 Solution

Accepted Solutions
NarelleChedzey
Esri Contributor

Hello, 

 

The problem here is your data. 

Annotation data from ArcMap needs to be upgraded in order to be editable and completely recognized within ArcGIS Pro.  Use the "Upgrade Dataset" GP tool to accomplish this. 

You can currently view the ArcMap annotation data in ArcGIS Pro, but if you jump to the "List by Editing" tab of the Contents pane you will see an exclamation point with a tooltip indicating the data is not editable.

image.png 

Once the tool is run, ArcGIS Pro will recognize your data as annotation features.and your code will cast to AnnotationFeatures successfully.

 

But an important note.  The Upgrade dataset GP tool will upgrade the feature class "in place".  A copy is not made.  Once the tool is run, the data can no longer be edited in ArcMap.  So if having the data in ArcMap format is important to you then you should make a copy of it first and run the GP tool on the copy. 

It is not possible to have annotation data editable in both ArcMap and Pro at the same time. 

 

In addition, here's some helpful information on working with annotations in the ArcGIS Pro API.

https://github.com/Esri/arcgis-pro-sdk/wiki/ProConcepts-Editing-Annotation

 

Hope this helps

Narelle

 

 

View solution in original post

3 Replies
UmaHarano
Esri Regular Contributor

Hi,

Here are some snippets relating to Annotations: ProSnippets: Annotation.

There is also a Concept doc available.

Thanks

Uma

NarelleChedzey
Esri Contributor

Hello, 

 

The problem here is your data. 

Annotation data from ArcMap needs to be upgraded in order to be editable and completely recognized within ArcGIS Pro.  Use the "Upgrade Dataset" GP tool to accomplish this. 

You can currently view the ArcMap annotation data in ArcGIS Pro, but if you jump to the "List by Editing" tab of the Contents pane you will see an exclamation point with a tooltip indicating the data is not editable.

image.png 

Once the tool is run, ArcGIS Pro will recognize your data as annotation features.and your code will cast to AnnotationFeatures successfully.

 

But an important note.  The Upgrade dataset GP tool will upgrade the feature class "in place".  A copy is not made.  Once the tool is run, the data can no longer be edited in ArcMap.  So if having the data in ArcMap format is important to you then you should make a copy of it first and run the GP tool on the copy. 

It is not possible to have annotation data editable in both ArcMap and Pro at the same time. 

 

In addition, here's some helpful information on working with annotations in the ArcGIS Pro API.

https://github.com/Esri/arcgis-pro-sdk/wiki/ProConcepts-Editing-Annotation

 

Hope this helps

Narelle

 

 

PetrDiviš
New Contributor III

Thank you both for great sources and quick help! The Update Dataset GP tool command solved my problem!

 

Cheers

 

Petr

0 Kudos