<?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 FGDB to EGDB Workspace error in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/fgdb-to-egdb-workspace-error/m-p/1537784#M72817</link>
    <description>&lt;P&gt;Hey all,&lt;/P&gt;&lt;P&gt;We identified some line geometries that need to have the order of their vertices replaced to utilize arrowhead symbology to visualize flow. We were successfully bale to piece together a script that worked on a feature class in a file gdb, but when trying to execute on our enterprise gdb it did not work and prompted the error message:&amp;nbsp;&lt;/P&gt;&lt;P&gt;Polyline - Reverse Geometry&lt;BR /&gt;=====================&lt;BR /&gt;Parameters&lt;/P&gt;&lt;P&gt;Input Feature Class SW Assets\dPipe&lt;BR /&gt;=====================&lt;BR /&gt;Messages&lt;/P&gt;&lt;P&gt;Start Time: Thursday, September 12, 2024 10:16:00 AM&lt;BR /&gt;Traceback (most recent call last):&lt;BR /&gt;File "&amp;lt;&amp;gt;\PublicWorksTools.atbx\PolylineReverseGeometry.tool\tool.script.execute.py", line 60, in &amp;lt;module&amp;gt;&lt;BR /&gt;File "&amp;lt;&amp;gt;\PublicWorksTools.atbx\PolylineReverseGeometry.tool\tool.script.execute.py", line 17, in reverse_line_geometry&lt;BR /&gt;RuntimeError: cannot open workspace&lt;/P&gt;&lt;P&gt;Failed script Polyline - Reverse Geometry...&lt;BR /&gt;Failed to execute (PolylineReverseGeometry).&lt;BR /&gt;Failed at Thursday, September 12, 2024 10:16:55 AM (Elapsed Time: 54.98 seconds)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;"""
Script documentation
- Tool parameters are accessed using arcpy.GetParameter() or 
                                     arcpy.GetParameterAsText()
- Update derived parameter values using arcpy.SetParameter() or
                                        arcpy.SetParameterAsText()
"""
import arcpy
def reverse_line_geometry(input_feature_class):
    """
    Reverses the direction of line geometries for selected records in the input feature class.
    
    :param input_feature_class: Path to the input line feature class
    """
    # Start an edit session
    workspace = arcpy.env.workspace
    edit = arcpy.da.Editor(workspace)
    edit.startEditing(False, True)
    edit.startOperation()
    
    try:
        # Use an update cursor to iterate through selected features
        with arcpy.da.UpdateCursor(input_feature_class, ["SHAPE@"]) as cursor:
            for row in cursor:
                # Get the current geometry
                geometry = row[0]
                
                # Reverse the order of points in each part of the polyline
                reversed_parts = []
                for part in geometry:
                    reversed_parts.append(arcpy.Array(part[::-1]))
                
                # Create a new polyline with the reversed parts
                reversed_geometry = arcpy.Polyline(arcpy.Array(reversed_parts))
                
                # Update the row with the reversed geometry
                row[0] = reversed_geometry
                cursor.updateRow(row)
        
        # Stop the edit operation
        edit.stopOperation()
        print("Successfully reversed the direction of selected line geometries.")
    
    except Exception as e:
        # Abort the edit operation in case of an error
        edit.abortOperation()
        print(f"An error occurred: {e}")
    
    finally:
        # Stop the edit session
        edit.stopEditing(True)
if __name__ == "__main__":
    # Retrieve parameters from the tool
    input_feature_class = arcpy.GetParameterAsText(0)
    
    # Set the workspace environment to the appropriate geodatabase
    arcpy.env.workspace = arcpy.Describe(input_feature_class).path
    
    # Call the function to reverse the line geometry
    reverse_line_geometry(input_feature_class)
&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance for any insight into how to correct this issue.&lt;/P&gt;</description>
    <pubDate>Thu, 12 Sep 2024 14:45:50 GMT</pubDate>
    <dc:creator>drWood</dc:creator>
    <dc:date>2024-09-12T14:45:50Z</dc:date>
    <item>
      <title>FGDB to EGDB Workspace error</title>
      <link>https://community.esri.com/t5/python-questions/fgdb-to-egdb-workspace-error/m-p/1537784#M72817</link>
      <description>&lt;P&gt;Hey all,&lt;/P&gt;&lt;P&gt;We identified some line geometries that need to have the order of their vertices replaced to utilize arrowhead symbology to visualize flow. We were successfully bale to piece together a script that worked on a feature class in a file gdb, but when trying to execute on our enterprise gdb it did not work and prompted the error message:&amp;nbsp;&lt;/P&gt;&lt;P&gt;Polyline - Reverse Geometry&lt;BR /&gt;=====================&lt;BR /&gt;Parameters&lt;/P&gt;&lt;P&gt;Input Feature Class SW Assets\dPipe&lt;BR /&gt;=====================&lt;BR /&gt;Messages&lt;/P&gt;&lt;P&gt;Start Time: Thursday, September 12, 2024 10:16:00 AM&lt;BR /&gt;Traceback (most recent call last):&lt;BR /&gt;File "&amp;lt;&amp;gt;\PublicWorksTools.atbx\PolylineReverseGeometry.tool\tool.script.execute.py", line 60, in &amp;lt;module&amp;gt;&lt;BR /&gt;File "&amp;lt;&amp;gt;\PublicWorksTools.atbx\PolylineReverseGeometry.tool\tool.script.execute.py", line 17, in reverse_line_geometry&lt;BR /&gt;RuntimeError: cannot open workspace&lt;/P&gt;&lt;P&gt;Failed script Polyline - Reverse Geometry...&lt;BR /&gt;Failed to execute (PolylineReverseGeometry).&lt;BR /&gt;Failed at Thursday, September 12, 2024 10:16:55 AM (Elapsed Time: 54.98 seconds)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;"""
Script documentation
- Tool parameters are accessed using arcpy.GetParameter() or 
                                     arcpy.GetParameterAsText()
- Update derived parameter values using arcpy.SetParameter() or
                                        arcpy.SetParameterAsText()
"""
import arcpy
def reverse_line_geometry(input_feature_class):
    """
    Reverses the direction of line geometries for selected records in the input feature class.
    
    :param input_feature_class: Path to the input line feature class
    """
    # Start an edit session
    workspace = arcpy.env.workspace
    edit = arcpy.da.Editor(workspace)
    edit.startEditing(False, True)
    edit.startOperation()
    
    try:
        # Use an update cursor to iterate through selected features
        with arcpy.da.UpdateCursor(input_feature_class, ["SHAPE@"]) as cursor:
            for row in cursor:
                # Get the current geometry
                geometry = row[0]
                
                # Reverse the order of points in each part of the polyline
                reversed_parts = []
                for part in geometry:
                    reversed_parts.append(arcpy.Array(part[::-1]))
                
                # Create a new polyline with the reversed parts
                reversed_geometry = arcpy.Polyline(arcpy.Array(reversed_parts))
                
                # Update the row with the reversed geometry
                row[0] = reversed_geometry
                cursor.updateRow(row)
        
        # Stop the edit operation
        edit.stopOperation()
        print("Successfully reversed the direction of selected line geometries.")
    
    except Exception as e:
        # Abort the edit operation in case of an error
        edit.abortOperation()
        print(f"An error occurred: {e}")
    
    finally:
        # Stop the edit session
        edit.stopEditing(True)
if __name__ == "__main__":
    # Retrieve parameters from the tool
    input_feature_class = arcpy.GetParameterAsText(0)
    
    # Set the workspace environment to the appropriate geodatabase
    arcpy.env.workspace = arcpy.Describe(input_feature_class).path
    
    # Call the function to reverse the line geometry
    reverse_line_geometry(input_feature_class)
&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance for any insight into how to correct this issue.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Sep 2024 14:45:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/fgdb-to-egdb-workspace-error/m-p/1537784#M72817</guid>
      <dc:creator>drWood</dc:creator>
      <dc:date>2024-09-12T14:45:50Z</dc:date>
    </item>
    <item>
      <title>Re: FGDB to EGDB Workspace error</title>
      <link>https://community.esri.com/t5/python-questions/fgdb-to-egdb-workspace-error/m-p/1537798#M72818</link>
      <description>&lt;P&gt;Is the feature class in a feature dataset? Because that will cause problems for sure. If it is, go up one level to the actual geodatabase.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is my initial idea for the issue&lt;STRIKE&gt;:&lt;/STRIKE&gt;&lt;/P&gt;&lt;P&gt;&lt;STRIKE&gt;Most likely, you're trying to access the Default version of the eGDB, and you don't have permissions to edit on the default. (Or something along those lines, idk)&lt;/STRIKE&gt;&lt;/P&gt;&lt;P&gt;&lt;STRIKE&gt;Try the following:&lt;/STRIKE&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;STRIKE&gt;Copy your SDE file&lt;/STRIKE&gt;&lt;/LI&gt;&lt;LI&gt;&lt;STRIKE&gt;In Catalog, right-click the copy and hit "Geodatabase Connection Properties"&lt;/STRIKE&gt;&lt;/LI&gt;&lt;LI&gt;&lt;STRIKE&gt;Change the version you're pointing to.&lt;/STRIKE&gt;&lt;/LI&gt;&lt;LI&gt;&lt;STRIKE&gt;Plug that the file from that version into your script instead. That is, go to that SDE file to pull out the feature class.&lt;/STRIKE&gt;&lt;/LI&gt;&lt;/OL&gt;</description>
      <pubDate>Thu, 12 Sep 2024 15:09:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/fgdb-to-egdb-workspace-error/m-p/1537798#M72818</guid>
      <dc:creator>AlfredBaldenweck</dc:creator>
      <dc:date>2024-09-12T15:09:19Z</dc:date>
    </item>
    <item>
      <title>Re: FGDB to EGDB Workspace error</title>
      <link>https://community.esri.com/t5/python-questions/fgdb-to-egdb-workspace-error/m-p/1545947#M72999</link>
      <description>&lt;P&gt;The feature class is indeed in a feature dataset. I'll give the script a&amp;nbsp; test on a feature class not residing within one and see if that works. Thanks in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Update: I ran the script on a standalone feature class within a different SDE and the execution errored out with the message "cannot update the table"&lt;/P&gt;</description>
      <pubDate>Sun, 06 Oct 2024 15:12:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/fgdb-to-egdb-workspace-error/m-p/1545947#M72999</guid>
      <dc:creator>drWood</dc:creator>
      <dc:date>2024-10-06T15:12:48Z</dc:date>
    </item>
    <item>
      <title>Re: FGDB to EGDB Workspace error</title>
      <link>https://community.esri.com/t5/python-questions/fgdb-to-egdb-workspace-error/m-p/1548704#M73026</link>
      <description>&lt;P&gt;Dumb question, but do you have permissions to edit it?&lt;/P&gt;</description>
      <pubDate>Tue, 15 Oct 2024 15:43:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/fgdb-to-egdb-workspace-error/m-p/1548704#M73026</guid>
      <dc:creator>AlfredBaldenweck</dc:creator>
      <dc:date>2024-10-15T15:43:14Z</dc:date>
    </item>
    <item>
      <title>Re: FGDB to EGDB Workspace error</title>
      <link>https://community.esri.com/t5/python-questions/fgdb-to-egdb-workspace-error/m-p/1555514#M73138</link>
      <description>&lt;P&gt;Not a dumb question, but I do indeed have editing permissions granted. There happens to be a gp tool called "Flip Line" that one of my interns came across. I for the life of me could not find it using nomenclature used in the GUI approach when "Edit Vertices" is active...&lt;/P&gt;</description>
      <pubDate>Tue, 05 Nov 2024 17:47:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/fgdb-to-egdb-workspace-error/m-p/1555514#M73138</guid>
      <dc:creator>drWood</dc:creator>
      <dc:date>2024-11-05T17:47:10Z</dc:date>
    </item>
  </channel>
</rss>

