<?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 Update Line Z Values in Attribute Rules Questions</title>
    <link>https://community.esri.com/t5/attribute-rules-questions/update-line-z-values/m-p/1504741#M1509</link>
    <description>&lt;P&gt;I am using the Utility Network and need a rule to change the Z value of each vertex in a line depending on the lifecycle status. I already wrote a rule for devices and it is working, but nothing I've tried for the lines is working. I am including the expression used for point features (devices). Could someone help with how to adapt this for line features?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// This rule updates the Z value of features based on the lifecycle status&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;var lcs = $feature["lifecyclestatus"];&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// Create a copy of the feature's geometry&lt;/P&gt;&lt;P&gt;var newGeom = Geometry($feature);&lt;/P&gt;&lt;P&gt;var newZ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// Update the Z value based on lifecycle status&lt;/P&gt;&lt;P&gt;// Domain values: proposed = 1, in service = 8, out of service = 256, abandoned = 32&lt;/P&gt;&lt;P&gt;if (lcs == 1) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; newZ = 1;&lt;/P&gt;&lt;P&gt;} else if (lcs == 8 {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; newZ = 0;&lt;/P&gt;&lt;P&gt;} else if (lcs == 256) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; newZ = -1;&lt;/P&gt;&lt;P&gt;} else if (lcs == 32) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; newZ = -2;&lt;/P&gt;&lt;P&gt;} else {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; newZ = 0;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// Create a new geometry with updated Z value&lt;/P&gt;&lt;P&gt;var updatedGeom = Point({&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "x": newGeom.x,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "y": newGeom.y,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "z": newZ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "spatialReference": newGeom.spatialReference&lt;/P&gt;&lt;P&gt;});&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// Return the updated geometry&lt;/P&gt;&lt;P&gt;return updatedGeom;&lt;/P&gt;</description>
    <pubDate>Fri, 12 Jul 2024 13:34:07 GMT</pubDate>
    <dc:creator>Justin_CLT</dc:creator>
    <dc:date>2024-07-12T13:34:07Z</dc:date>
    <item>
      <title>Update Line Z Values</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/update-line-z-values/m-p/1504741#M1509</link>
      <description>&lt;P&gt;I am using the Utility Network and need a rule to change the Z value of each vertex in a line depending on the lifecycle status. I already wrote a rule for devices and it is working, but nothing I've tried for the lines is working. I am including the expression used for point features (devices). Could someone help with how to adapt this for line features?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// This rule updates the Z value of features based on the lifecycle status&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;var lcs = $feature["lifecyclestatus"];&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// Create a copy of the feature's geometry&lt;/P&gt;&lt;P&gt;var newGeom = Geometry($feature);&lt;/P&gt;&lt;P&gt;var newZ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// Update the Z value based on lifecycle status&lt;/P&gt;&lt;P&gt;// Domain values: proposed = 1, in service = 8, out of service = 256, abandoned = 32&lt;/P&gt;&lt;P&gt;if (lcs == 1) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; newZ = 1;&lt;/P&gt;&lt;P&gt;} else if (lcs == 8 {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; newZ = 0;&lt;/P&gt;&lt;P&gt;} else if (lcs == 256) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; newZ = -1;&lt;/P&gt;&lt;P&gt;} else if (lcs == 32) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; newZ = -2;&lt;/P&gt;&lt;P&gt;} else {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; newZ = 0;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// Create a new geometry with updated Z value&lt;/P&gt;&lt;P&gt;var updatedGeom = Point({&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "x": newGeom.x,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "y": newGeom.y,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "z": newZ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "spatialReference": newGeom.spatialReference&lt;/P&gt;&lt;P&gt;});&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// Return the updated geometry&lt;/P&gt;&lt;P&gt;return updatedGeom;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jul 2024 13:34:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/update-line-z-values/m-p/1504741#M1509</guid>
      <dc:creator>Justin_CLT</dc:creator>
      <dc:date>2024-07-12T13:34:07Z</dc:date>
    </item>
    <item>
      <title>Re: Update Line Z Values</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/update-line-z-values/m-p/1504742#M1510</link>
      <description>&lt;P&gt;Geometry is immutable, so convert to dictionary&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var p = Polyline(
  {
    paths: [
      [
        [-97.06138, 32.837, 0],
        [-97.06133, 32.836, 0],
        [-97.06124, 32.834, 0],
        [-97.06127, 32.832, 0]
      ]
    ],
    hasZ: true,
    spatialReference: { wkid: 3857 }
  }
);
console(p);

var p_z = Dictionary(p)
for(var i in p_z['paths']){
  for(var j in p_z['paths'][i]){

    p_z['paths'][i][j][2] = 50
  }
}
return Polyline(p_z)&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 12 Jul 2024 12:47:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/update-line-z-values/m-p/1504742#M1510</guid>
      <dc:creator>MikeMillerGIS</dc:creator>
      <dc:date>2024-07-12T12:47:49Z</dc:date>
    </item>
    <item>
      <title>Re: Update Line Z Values</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/update-line-z-values/m-p/1504832#M1511</link>
      <description>&lt;P&gt;I got it to work for lines using the following expression:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// This rule updates the Z value of linear features based on the lifecycle status&lt;BR /&gt;var lcs = $feature["lifecyclestatus"];&lt;/P&gt;&lt;P&gt;// Create a copy of the feature's geometry&lt;BR /&gt;var newGeom = Geometry($feature);&lt;BR /&gt;var newPaths = [];&lt;/P&gt;&lt;P&gt;// Update the Z value based on lifecycle status&lt;BR /&gt;// Domain values: proposed = 1, in service = 8, out of service = 256, abandoned = 32&lt;BR /&gt;var newZ;&lt;BR /&gt;if (lcs == 1) {&lt;BR /&gt;newZ = 5;&lt;BR /&gt;} else if (lcs == 8 {&lt;BR /&gt;newZ = 0;&lt;BR /&gt;} else if (lcs == 256) {&lt;BR /&gt;newZ = -5;&lt;BR /&gt;} else if (lcs == 32) {&lt;BR /&gt;newZ = -10;&lt;BR /&gt;} else {&lt;BR /&gt;newZ = 0;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// Iterate through each part of the polyline&lt;BR /&gt;for (var i = 0; i &amp;lt; Count(newGeom.paths); i++) {&lt;BR /&gt;var path = newGeom.paths[i];&lt;BR /&gt;var newPath = [];&lt;BR /&gt;// Iterate through each vertex in the part&lt;BR /&gt;for (var v = 0; v &amp;lt; Count(path); v++) {&lt;BR /&gt;var point = path[v];&lt;BR /&gt;// Create a new point with updated Z value and original X and Y coordinates&lt;BR /&gt;var newPoint = [point.x, point.y, newZ];&lt;BR /&gt;// Add the new point to the new path&lt;BR /&gt;Push(newPath, newPoint);&lt;BR /&gt;}&lt;BR /&gt;// Add the new path to the new paths array&lt;BR /&gt;Push(newPaths, newPath);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// Create a new polyline with updated Z values&lt;BR /&gt;var updatedGeom = Polyline({&lt;BR /&gt;"paths": newPaths,&lt;BR /&gt;"spatialReference": newGeom.spatialReference&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;// Return the updated geometry&lt;BR /&gt;return updatedGeom;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jul 2024 15:09:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/update-line-z-values/m-p/1504832#M1511</guid>
      <dc:creator>Justin_CLT</dc:creator>
      <dc:date>2024-07-12T15:09:08Z</dc:date>
    </item>
    <item>
      <title>Re: Update Line Z Values</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/update-line-z-values/m-p/1504837#M1512</link>
      <description>&lt;P&gt;Related:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;A href="https://community.esri.com/t5/arcgis-pro-ideas/arcade-docs-working-with-vertices/idi-p/1152038" target="_self"&gt;Arcade docs: Working with vertices&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;&lt;A href="https://community.esri.com/t5/arcgis-pro-questions/arcade-code-review-set-polyline-m-values-to/m-p/1153012/highlight/true#M52698" target="_self"&gt;Arcade Code Review: Set polyline M-values to cumulative length of line&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;&lt;A href="https://github.com/Esri/arcade-expressions/blob/master/attribute_rule_calculation/SetMValues.md" target="_self"&gt;SetMValues - GitHub&lt;/A&gt; (Calculate M values of a line using vertex distance)&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;Edit:&lt;/STRONG&gt;&amp;nbsp;&lt;A href="https://community.esri.com/t5/attribute-rules-questions/arcade-modify-only-z-geometry/m-p/1364723/highlight/true#M1225" target="_self"&gt;Arcade modify only Z geometry&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;</description>
      <pubDate>Fri, 12 Jul 2024 15:49:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/update-line-z-values/m-p/1504837#M1512</guid>
      <dc:creator>Bud</dc:creator>
      <dc:date>2024-07-12T15:49:20Z</dc:date>
    </item>
  </channel>
</rss>

