Editing features on another class with attribute rules - Points

515
5
Jump to solution
04-27-2022 01:03 PM
Jake_S
by
Occasional Contributor II

Hey folks,

Stumbled upon this post, Advanced Attribute Rules - Editing features on another class with attribute rules where inserting a point created a buffer polygon feature class. I wanted to use this when a user creates an annotation feature a similar rule would create a point feature class. When I use almost identical code just pointed to a point feature class. 

 

 

var featureGeo = Geometry($feature);
return {
      "result": $feature.OBJECT__ID,
      "edit": [  
        {  
            "className" : "LocalPoints", 
            "adds" : [   
                   {
                         "attributes":  
                          {
                                "TextString": $feature.TextString
                            }, 
                         "geometry": featureGeo
                   }
          ]
         }  
  ]
}

 

 

 

I get the following error..

JS_Esri_0-1651089663256.png

Am I using the wrong function to return the annotation feature geometry? Or is it my Pro Version? 2.6.6

Any help for this noob is appreciated!

~j 

0 Kudos
1 Solution

Accepted Solutions
JohannesLindner
MVP Frequent Contributor

Annotation features seem to be treated as polygons. So when you try to just copy the geometry to a point fc, it throws an error.

Depending on where you want the point to show up, you have a few options:

  • Centroid(featureGeo), this will place the point in the center of the annotation
  • featureGeo.rings[0][1], this will place the point at the bottom left corner of the annotation
  • featureGeo.ring[0][X], where X is 0, 2 or 3, this will place the point at one of the other corners

Have a great day!
Johannes

View solution in original post

5 Replies
JohannesLindner
MVP Frequent Contributor

Annotation features seem to be treated as polygons. So when you try to just copy the geometry to a point fc, it throws an error.

Depending on where you want the point to show up, you have a few options:

  • Centroid(featureGeo), this will place the point in the center of the annotation
  • featureGeo.rings[0][1], this will place the point at the bottom left corner of the annotation
  • featureGeo.ring[0][X], where X is 0, 2 or 3, this will place the point at one of the other corners

Have a great day!
Johannes
Jake_S
by
Occasional Contributor II

Johannes, 

Always looking out for me!

I did try Centroid() prior to posting, I get the following error:

JS_Esri_0-1651134408239.png

Using featureGeo.rings[0][1] returns this error:

JS_Esri_2-1651134506214.png

After these attempts, your statement "Annotation features seem to be treated as polygons." got me thinking so when I did the following, I got the desired output!

var buff = Buffer($feature,1)
var featureGeo = Centroid(buff)

Creating a small buffer then getting the centroid did the trick!

Thank you for your help. As always its a pleasure!

0 Kudos
Jake_S
by
Occasional Contributor II

This also worked......

var featureGeo = Geometry($feature);
var featureGeo = Centroid(featureGeo)
0 Kudos
JohannesLindner
MVP Frequent Contributor

Huh, weird, these snippets worked for me. But my test feature classes are in a file gdb, maybe that makes a difference, who knows...

Glad you got it to work with the buffer!


Have a great day!
Johannes
0 Kudos
Jake_S
by
Occasional Contributor II

Yeah, not sure. Enjoy the day!

0 Kudos