<?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: Calculation rule for line cutting in Attribute Rules Questions</title>
    <link>https://community.esri.com/t5/attribute-rules-questions/calculation-rule-for-line-cutting/m-p/1170511#M406</link>
    <description>&lt;P&gt;It should be possible. Something like this (completely untested!)&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// Calculation Attribute Rule on LineFC
// Field: empty
// triggers: insert(, update)

// load the whole LineFC
var line_fs = FeatureSetByNAme($datastore, "LineFC", ["GlobalID"], true)

// get the intersecting lines
var intersect_lines = Intersects(line_fs, $feature)

// create and fill adds and deletes arrays
var adds = []
var deletes = []
for(var i_line in intersect_lines) {
    // get intersection geometry
    var i_geom = Intersection(i_line, $feature)
    // there are multiple conditions where we don't want to cut the line:
        // intersection isn't a point (overlapping lines or i_line == $feature)
        // i_line is intersecting $feature on start or end point
    if(i_geom.type != "Point" ||
       Equals(i_geom, Geometry(i_line).paths[0][0] ||
       Equals(i_geom, Geometry(i_line).paths[-1][-1] ) {
        continue
    }
    // cut i_line with $feature, delete the original, add the cut parts
    var cut_parts = Cut(i_line, $feature)
    Push(deletes, {"globalID": i_line.GlobalID})
    for(var p in cut_parts) {
        Push(adds, {"geometry": cut_parts[p]})
    }
}
// apply the edits
return {
    "edit": [
        {
            "className": "LineFC",
            "adds": adds,
            "deletes": deletes
        }
    ]
}&lt;/LI-CODE&gt;</description>
    <pubDate>Wed, 04 May 2022 06:32:23 GMT</pubDate>
    <dc:creator>JohannesLindner</dc:creator>
    <dc:date>2022-05-04T06:32:23Z</dc:date>
    <item>
      <title>Calculation rule for line cutting</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/calculation-rule-for-line-cutting/m-p/1170373#M405</link>
      <description>&lt;P&gt;Hello ESRI people,&lt;/P&gt;&lt;P&gt;I am thinking if it is possible to cut a line at the intersection of an inserted line.&amp;nbsp;&lt;/P&gt;&lt;P&gt;It seems like we can achieve this by a point of point feature class for cutting a line of line feature class. But I am just wondering if we can do by only using a single line feature class, i.e.&amp;nbsp;Both the target line and the inserted line are same feature class.&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Tue, 03 May 2022 20:35:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/calculation-rule-for-line-cutting/m-p/1170373#M405</guid>
      <dc:creator>HNTZK46</dc:creator>
      <dc:date>2022-05-03T20:35:24Z</dc:date>
    </item>
    <item>
      <title>Re: Calculation rule for line cutting</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/calculation-rule-for-line-cutting/m-p/1170511#M406</link>
      <description>&lt;P&gt;It should be possible. Something like this (completely untested!)&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// Calculation Attribute Rule on LineFC
// Field: empty
// triggers: insert(, update)

// load the whole LineFC
var line_fs = FeatureSetByNAme($datastore, "LineFC", ["GlobalID"], true)

// get the intersecting lines
var intersect_lines = Intersects(line_fs, $feature)

// create and fill adds and deletes arrays
var adds = []
var deletes = []
for(var i_line in intersect_lines) {
    // get intersection geometry
    var i_geom = Intersection(i_line, $feature)
    // there are multiple conditions where we don't want to cut the line:
        // intersection isn't a point (overlapping lines or i_line == $feature)
        // i_line is intersecting $feature on start or end point
    if(i_geom.type != "Point" ||
       Equals(i_geom, Geometry(i_line).paths[0][0] ||
       Equals(i_geom, Geometry(i_line).paths[-1][-1] ) {
        continue
    }
    // cut i_line with $feature, delete the original, add the cut parts
    var cut_parts = Cut(i_line, $feature)
    Push(deletes, {"globalID": i_line.GlobalID})
    for(var p in cut_parts) {
        Push(adds, {"geometry": cut_parts[p]})
    }
}
// apply the edits
return {
    "edit": [
        {
            "className": "LineFC",
            "adds": adds,
            "deletes": deletes
        }
    ]
}&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 04 May 2022 06:32:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/calculation-rule-for-line-cutting/m-p/1170511#M406</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2022-05-04T06:32:23Z</dc:date>
    </item>
    <item>
      <title>Re: Calculation rule for line cutting</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/calculation-rule-for-line-cutting/m-p/1170877#M407</link>
      <description>&lt;P&gt;Hi Johannes,&lt;/P&gt;&lt;P&gt;I applied your Arcade expression for a line feature class but unfortunately got an error, saying "Arcade error: Unexpected null, Script line: 20".&lt;/P&gt;&lt;P&gt;Unfortunately I don't know how to workaround this. If you could tell me any solution to this, that would be much appreciated.&lt;/P&gt;</description>
      <pubDate>Wed, 04 May 2022 21:48:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/calculation-rule-for-line-cutting/m-p/1170877#M407</guid>
      <dc:creator>HNTZK46</dc:creator>
      <dc:date>2022-05-04T21:48:30Z</dc:date>
    </item>
    <item>
      <title>Re: Calculation rule for line cutting</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/calculation-rule-for-line-cutting/m-p/1170957#M408</link>
      <description>&lt;P&gt;Include a null check in the conditions:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;    if(i_geom == null || i_geom.type != "Point" ||
       Equals(i_geom, Geometry(i_line).paths[0][0] ||
       Equals(i_geom, Geometry(i_line).paths[-1][-1] ) {
        continue
    }&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 05 May 2022 04:53:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/calculation-rule-for-line-cutting/m-p/1170957#M408</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2022-05-05T04:53:13Z</dc:date>
    </item>
  </channel>
</rss>

