<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Edit geometry using calculation attribute rule in ArcGIS Pro 2.5 in Attribute Rules Questions</title>
    <link>https://community.esri.com/t5/attribute-rules-questions/edit-geometry-using-calculation-attribute-rule-in/m-p/1157697#M364</link>
    <description>&lt;P&gt;Thanks very much. That helps.&lt;/P&gt;&lt;P&gt;As you suggested, I'm looking into updating my version of Pro:&lt;BR /&gt;&lt;A href="https://community.esri.com/t5/arcgis-pro-questions/what-versions-of-pro-are-compatible-with-10-7-1/td-p/1157695" target="_self"&gt;What versions of Pro are compatible with 10.7.1 EGDBs?&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 25 Mar 2022 08:18:08 GMT</pubDate>
    <dc:creator>Bud</dc:creator>
    <dc:date>2022-03-25T08:18:08Z</dc:date>
    <item>
      <title>Edit geometry using calculation attribute rule in ArcGIS Pro 2.5</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/edit-geometry-using-calculation-attribute-rule-in/m-p/1157450#M362</link>
      <description>&lt;P&gt;I have a calculation attribute rule that updates polyline geometries:&amp;nbsp;&lt;A href="https://community.esri.com/t5/arcgis-pro-questions/code-review-set-polyline-m-values-to-cumulative/m-p/1155856/highlight/true#M53075" target="_self"&gt;Set polyline M-values to cumulative length of line&lt;/A&gt;. That attribute rule works as expected in ArcGIS Pro 2.9.2 / FGDB (test environment).&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Now, I want to use it in our 10.7.1 EGDB and &lt;STRONG&gt;ArcGIS Pro 2.5.0&lt;/STRONG&gt; (production environment).&lt;BR /&gt;When I go to create the rule, I notice that the Field is mandatory, yet the SHAPE field is missing from the field list:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Bud_0-1648144754602.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/37266i65E65B3EC227ABA1/image-size/large?v=v2&amp;amp;px=999" role="button" title="Bud_0-1648144754602.png" alt="Bud_0-1648144754602.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;(That's different than 2.9.2 -- the field isn't mandatory in 2.9.2, and the SHAPE field shows up in the list.)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;If the Field is mandatory in 2.5.0, and the SHAPE field is missing from the list, then how can I create an attribute rule that updates the geometry?&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Mar 2022 19:45:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/edit-geometry-using-calculation-attribute-rule-in/m-p/1157450#M362</guid>
      <dc:creator>Bud</dc:creator>
      <dc:date>2022-03-24T19:45:52Z</dc:date>
    </item>
    <item>
      <title>Re: Edit geometry using calculation attribute rule in ArcGIS Pro 2.5</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/edit-geometry-using-calculation-attribute-rule-in/m-p/1157687#M363</link>
      <description>&lt;P&gt;These were changes made in 2.6 (geometry updates) and 2.7 (update multiple fields). Arcade and Attribute Rules are under active development, so sadly, something like this is bound to happen now and then.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;how can I create an attribute rule that updates the geometry?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;In 2.5, you can't.*&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;You'll have to update your production environment. Pro 2.7 should be enough for your rule, but go take a look at the &lt;A href="https://developers.arcgis.com/arcade/guide/release-notes/" target="_self"&gt;Arcade Release History&lt;/A&gt;, maybe there are some functions you want to use from later releases. Combined with the &lt;A href="https://developers.arcgis.com/arcade/guide/version-matrix/" target="_self"&gt;Arcade Version Matrix&lt;/A&gt;, this will tell you the versions of Pro and Enterprise.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;*: Well, &lt;STRONG&gt;maybe&lt;/STRONG&gt; (I didn't check versions or test this) you can update the geometries from another table:&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// Calculation Attribute Rule on GeometryUpdateControlTable
// field: DoItNow (integer field, 1 means "update now")
// triggers: update

// requires another field: ObjectIDsToBeEdited  (Text field with comma separated ObjectIDs of the polyline features. Null means all.)

var fs_polylines = FeatureSetByName($datastore, "PolylineFC", ["OBJECTID"], true)
if(!IsEmpty($feature.ObjectIDsToBeEdited)) {
    var where = `ObjectID IN (${$feature.ObjectIDsToBeEdited})`
    fs_polylines = Filter(fs_polylines, where)
}

var polyline_updates = []
for(var f in fs_polylines) {
    var geom = Dictionary(Text(Geometry(f)))  // f instead of $feature
    var paths = geom['paths']

    var oldX = paths[0][0][0];
    var oldY = paths[0][0][1];
    var line_length = 0;

    for (var path_idx in paths) {
        for (var point_idx in paths[path_idx]) {
            var newX = paths[path_idx][point_idx][0];
            var newY = paths[path_idx][point_idx][1];
            //For multi-part features, we want the M-value for additional     parts to start at the last M-value from the last part. We don't want to     measure the distance *between* parts.
            //So, for the first vertex in a given part, we will skip calculating the length between vertices.
            if (point_idx != 0) {
                line_length += pythagoras(oldX, oldY, newX, newY);
            }
            //We can use a negative slice: it will work when there is no Z.
            paths[path_idx][point_idx][-1] = line_length;
            oldX = newX;
            oldY = newY;
        }
    }
    Push(polyline_updates, {"objectID": f.OBJECTID, "geometry": Polyline(geom)})
}

return {
    "result": 0,
    "edit": [
        {
            "className": "Database.Dataowner.PolylineFC",
            "updates": polyline_updates
        }
    ]
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This way, you could start the calculation manually by setting DoItNow to 1. Also, you could do it automatically:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// Calculation Attribute Rule on PolylineFC
// field: SomeField that is editable
// triggers: update

if (Text(Geometry($feature)) == Text(Geometry($originalfeature))) {
    console("The geometry has not changed. We don't need to redefine the M-Values.")
    return $feature.SomeField
}

console("The geometry has changed. So we *will* redefine the M-Values.")
return {
    "result": $feature.SomeField,
    "edit": [
        {
            "className": "Database.Dataowner.GeometryUpdateControlTable",
            "updates": [{
                "objectID": 1, "attributes": {
                    "ObjectIDsToBeEdited": Text($feature.ObjectID),
                    "DoItNow": 1
            }}]
        }
    ]
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Mar 2022 06:49:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/edit-geometry-using-calculation-attribute-rule-in/m-p/1157687#M363</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2022-03-25T06:49:28Z</dc:date>
    </item>
    <item>
      <title>Re: Edit geometry using calculation attribute rule in ArcGIS Pro 2.5</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/edit-geometry-using-calculation-attribute-rule-in/m-p/1157697#M364</link>
      <description>&lt;P&gt;Thanks very much. That helps.&lt;/P&gt;&lt;P&gt;As you suggested, I'm looking into updating my version of Pro:&lt;BR /&gt;&lt;A href="https://community.esri.com/t5/arcgis-pro-questions/what-versions-of-pro-are-compatible-with-10-7-1/td-p/1157695" target="_self"&gt;What versions of Pro are compatible with 10.7.1 EGDBs?&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Mar 2022 08:18:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/edit-geometry-using-calculation-attribute-rule-in/m-p/1157697#M364</guid>
      <dc:creator>Bud</dc:creator>
      <dc:date>2022-03-25T08:18:08Z</dc:date>
    </item>
  </channel>
</rss>

