<?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 Trace Geometric Network got ERROR 000366 only with arcpy in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/trace-geometric-network-got-error-000366-only-with/m-p/1555818#M73141</link>
    <description>&lt;P&gt;Hi, I've created a tool that selects some layers by attribute and others by location, then in the end it makes a Trace Geometric Network. When I run the tool by "Edit Mode" everything is okay , the group layer is created and added to the map.&lt;/P&gt;&lt;P&gt;But when I export the python script (because I need to modify it later) and just copy and paste it&amp;nbsp; inside the python window of geoprocessing section, it breaks at the final step, the&amp;nbsp;Trace Geometric Network, with the error: "Failed to execute. Parameters are not valid. ERROR 000366: Invalid geometry type Failed to execute (TraceGeometricNetwork)."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the last line of the script, that throws the error:&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;&lt;SPAN&gt;# Process: Trace Geometric Network&lt;BR /&gt;&lt;/SPAN&gt;arcpy.TraceGeometricNetwork_management(RETEAD_BT_Net__2_&lt;SPAN&gt;, &lt;/SPAN&gt;GruppoCS_75460&lt;SPAN&gt;, &lt;/SPAN&gt;Interruttori_BT__2_&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"FIND_CONNECTED"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;""&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;""&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;""&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;""&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;""&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"NO_TRACE_ENDS"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"NO_TRACE_INDETERMINATE_FLOW"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;""&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;""&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"AS_IS"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;""&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;""&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;""&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"AS_IS"&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;/DIV&gt;</description>
    <pubDate>Wed, 06 Nov 2024 14:33:58 GMT</pubDate>
    <dc:creator>TeresaBartolomei</dc:creator>
    <dc:date>2024-11-06T14:33:58Z</dc:date>
    <item>
      <title>Trace Geometric Network got ERROR 000366 only with arcpy</title>
      <link>https://community.esri.com/t5/python-questions/trace-geometric-network-got-error-000366-only-with/m-p/1555818#M73141</link>
      <description>&lt;P&gt;Hi, I've created a tool that selects some layers by attribute and others by location, then in the end it makes a Trace Geometric Network. When I run the tool by "Edit Mode" everything is okay , the group layer is created and added to the map.&lt;/P&gt;&lt;P&gt;But when I export the python script (because I need to modify it later) and just copy and paste it&amp;nbsp; inside the python window of geoprocessing section, it breaks at the final step, the&amp;nbsp;Trace Geometric Network, with the error: "Failed to execute. Parameters are not valid. ERROR 000366: Invalid geometry type Failed to execute (TraceGeometricNetwork)."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the last line of the script, that throws the error:&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;&lt;SPAN&gt;# Process: Trace Geometric Network&lt;BR /&gt;&lt;/SPAN&gt;arcpy.TraceGeometricNetwork_management(RETEAD_BT_Net__2_&lt;SPAN&gt;, &lt;/SPAN&gt;GruppoCS_75460&lt;SPAN&gt;, &lt;/SPAN&gt;Interruttori_BT__2_&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"FIND_CONNECTED"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;""&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;""&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;""&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;""&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;""&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"NO_TRACE_ENDS"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"NO_TRACE_INDETERMINATE_FLOW"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;""&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;""&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"AS_IS"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;""&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;""&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;""&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"AS_IS"&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 06 Nov 2024 14:33:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trace-geometric-network-got-error-000366-only-with/m-p/1555818#M73141</guid>
      <dc:creator>TeresaBartolomei</dc:creator>
      <dc:date>2024-11-06T14:33:58Z</dc:date>
    </item>
    <item>
      <title>Re: Trace Geometric Network got ERROR 000366 only with arcpy</title>
      <link>https://community.esri.com/t5/python-questions/trace-geometric-network-got-error-000366-only-with/m-p/1556826#M73164</link>
      <description>&lt;P&gt;Try referencing the layer directly by name instead of by group. Group layer&amp;nbsp; may not translate correct.&lt;/P&gt;&lt;P&gt;Try this, there is some debugging parameters to check for empty geometries.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;import arcpy

# Define your inputs
RETEAD_BT_Net__2_ = "in_geometric_network"
GruppoCS_75460 = "group_layer" #out_network_layer
Interruttori_BT__2_ = "switches_layer" #in_flags

try:
    # Describe the inputs to check their geometry types
    desc_network = arcpy.Describe(RETEAD_BT_Net__2_)
    desc_group = arcpy.Describe(GruppoCS_75460)
    desc_switches = arcpy.Describe(Interruttori_BT__2_)

    print(f"Network Geometry Type: {desc_network.shapeType}")
    print(f"Group Layer Geometry Type: {desc_group.shapeType}")
    print(f"Switches Layer Geometry Type: {desc_switches.shapeType}")

    # Ensure the inputs are not empty
    network_count = int(arcpy.GetCount_management(RETEAD_BT_Net__2_).getOutput(0))
    group_count = int(arcpy.GetCount_management(GruppoCS_75460).getOutput(0))
    switches_count = int(arcpy.GetCount_management(Interruttori_BT__2_).getOutput(0))

    print(f"Network Feature Count: {network_count}")
    print(f"Group Layer Feature Count: {group_count}")
    print(f"Switches Layer Feature Count: {switches_count}")

    if network_count == 0 or group_count == 0 or switches_count == 0:
        raise ValueError("One or more input layers are empty.")

    # Process: Trace Geometric Network
    arcpy.TraceGeometricNetwork_management(
        RETEAD_BT_Net__2_, GruppoCS_75460, Interruttori_BT__2_, 
        "FIND_CONNECTED", "", "", "", "", "", 
        "NO_TRACE_ENDS", "NO_TRACE_INDETERMINATE_FLOW", "", "", 
        "AS_IS", "", "", "", "AS_IS"
    )

    print("Trace Geometric Network completed successfully.")

except arcpy.ExecuteError:
    print(f"Geoprocessing error: {arcpy.GetMessages(2)}")
except Exception as e:
    print(f"An error occurred: {e}")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Nov 2024 15:46:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trace-geometric-network-got-error-000366-only-with/m-p/1556826#M73164</guid>
      <dc:creator>TonyAlmeida</dc:creator>
      <dc:date>2024-11-08T15:46:42Z</dc:date>
    </item>
  </channel>
</rss>

