<?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: Python code error in Transportation Questions</title>
    <link>https://community.esri.com/t5/transportation-questions/python-code-error/m-p/500008#M1665</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: Wayne_Whitley&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Your desired end product is to produce lines that loop on themselves?&amp;nbsp; Without looking at your data, are you sure this will produce the shapes intended, legitimate geometry?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I see you're establishing the workspace which you are both reading and writing from with:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;env.workspace = "C:\\Users\\Luke Kaim\\Documents\\University of Maine\\Fall_2012\\Volunteer Geographic Information\\Data\\test"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But you're reading/writing to/from a gdb, so set your workspace directly to that with:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;env.workspace = "C:\\Users\\Luke Kaim\\Documents\\University of Maine\\Fall_2012\\Volunteer Geographic Information\\Data\\test\\selectedlines.gdb"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Then your variables, infile and outfile (which are really feature classes), can be defined simply as:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;infile = "line"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;outfile = "testline"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This line (below, with the 'w' parameter [which means 'write' mode]) doesn't make sense - looks like you were trying to adapt code for writing to a text file (use the line above for defining the variable outfile)--&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;outfile = (r"C:\Users\Luke Kaim\Documents\University of Maine\Fall_2012\Volunteer Geographic Information\Data\test\selectedlines.gdb\testline", 'w')&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, you'll need to change your parameters for Create Feature Class to accept the way you've defined infile and outfile - this more direct approach should work:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.CreateFeatureclass_management(env.workspace, outfile,"Polyline", infile)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For running this script on a selected set, you can run your search cursor initially set up with a query to define a selected set.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope that helps.&amp;nbsp; Also, next time you post, it would be helpful to include any error messages that may result.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 31 Oct 2012 11:51:17 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2012-10-31T11:51:17Z</dc:date>
    <item>
      <title>Python code error</title>
      <link>https://community.esri.com/t5/transportation-questions/python-code-error/m-p/500007#M1664</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: luke.kaim&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi Everyone,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Let me start by thanking you in advance.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The problem I am encountering is that line features do not close on themselves. I need to go through every line feature, select the first point X,Y coordinate store that point X,Y coordinate and add it to the end of the line Array. This will then close the line feature which is the desired goal of the code. I am trying to do this using the insert and search cursor. The code is not working though. My first issue is that the code will not create a feature class and then output it to the correct directory. I am not sure if I have the correct logic as well. Would you be able to look at the below code? I can also add a feature class which is a selection of the data.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;# Luke Kaim 10/26/12 # The goal of this code is to close all line features such that the first coordinate and the last coordinate of a feature match.&amp;nbsp; # Import arcpy module import arcpy, sys, os, re import arcpy from arcpy import env&amp;nbsp; env.overwriteOutput = True env.workspace = "C:\\Users\\Luke Kaim\\Documents\\University of Maine\\Fall_2012\\Volunteer Geographic Information\\Data\\test"&amp;nbsp;&amp;nbsp; # Get the output feature class infile = r"C:\Users\Luke Kaim\Documents\University of Maine\Fall_2012\Volunteer Geographic Information\Data\test\selectedlines.gdb\line"&amp;nbsp; outfile = (r"C:\Users\Luke Kaim\Documents\University of Maine\Fall_2012\Volunteer Geographic Information\Data\test\selectedlines.gdb\testline", 'w')&amp;nbsp;&amp;nbsp;&amp;nbsp; # Identify the geometry field desc = arcpy.Describe(infile) shapefieldname = desc.ShapeFieldName OIDFieldName = desc.OIDFieldName&amp;nbsp;&amp;nbsp;&amp;nbsp; try: &amp;nbsp;&amp;nbsp; # Create the output feature class &amp;nbsp;&amp;nbsp; # &amp;nbsp;&amp;nbsp; #arcpy.CreateFeatureclass(path,name,"POLYLINE", infile) &amp;nbsp;&amp;nbsp; arcpy.CreateFeatureclass_management(os.path.dirname(outfile), &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; os.path.basename(outfile),&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Polyline", infile)&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; rows = arcpy.SearchCursor(infile) &amp;nbsp;&amp;nbsp; cur = arcpy.InsertCursor(outfile)&amp;nbsp; &amp;nbsp;&amp;nbsp; # Create an array and point object needed to create features &amp;nbsp;&amp;nbsp; lineArray = arcpy.Array() &amp;nbsp;&amp;nbsp; pnt = arcpy.Point() &amp;nbsp;&amp;nbsp;&amp;nbsp; # Iterate through the rows in the cursor&amp;nbsp; &amp;nbsp;&amp;nbsp; for row in rows: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Create the geometry object&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; feat = row.getValue(shapefieldname) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Print the current multipoint's ID&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Feature %i:" % row.getValue(desc.OIDFieldName) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; partnum = 0&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Step through each part of the feature&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for part in feat: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Print the part number &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Part %i:" % partnum&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Step through each vertex in the feature &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for pnt in feat.getPart(partnum): &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if pnt: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Print x,y coordinates of current point &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print pnt.X, pnt.Y &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if partnum==1: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; firstpnt.X=pnt.X &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; firstpnt.Y=pnt.Y&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lineArray.add(pnt) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; feat = cur.newRow()&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Set the geometry of the new feature to the array of points &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lineArray.add(firstpnt) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; feat.shape = lineArray&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Insert the feature&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; cur.insertRow(feat) &amp;nbsp;&amp;nbsp; lineArray.removeAll()&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; partnum += 1&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; del cur, rows except Exception as e: &amp;nbsp;&amp;nbsp; print e.message&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 31 Oct 2012 10:35:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/python-code-error/m-p/500007#M1664</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2012-10-31T10:35:24Z</dc:date>
    </item>
    <item>
      <title>Re: Python code error</title>
      <link>https://community.esri.com/t5/transportation-questions/python-code-error/m-p/500008#M1665</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: Wayne_Whitley&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Your desired end product is to produce lines that loop on themselves?&amp;nbsp; Without looking at your data, are you sure this will produce the shapes intended, legitimate geometry?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I see you're establishing the workspace which you are both reading and writing from with:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;env.workspace = "C:\\Users\\Luke Kaim\\Documents\\University of Maine\\Fall_2012\\Volunteer Geographic Information\\Data\\test"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But you're reading/writing to/from a gdb, so set your workspace directly to that with:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;env.workspace = "C:\\Users\\Luke Kaim\\Documents\\University of Maine\\Fall_2012\\Volunteer Geographic Information\\Data\\test\\selectedlines.gdb"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Then your variables, infile and outfile (which are really feature classes), can be defined simply as:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;infile = "line"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;outfile = "testline"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This line (below, with the 'w' parameter [which means 'write' mode]) doesn't make sense - looks like you were trying to adapt code for writing to a text file (use the line above for defining the variable outfile)--&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;outfile = (r"C:\Users\Luke Kaim\Documents\University of Maine\Fall_2012\Volunteer Geographic Information\Data\test\selectedlines.gdb\testline", 'w')&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, you'll need to change your parameters for Create Feature Class to accept the way you've defined infile and outfile - this more direct approach should work:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.CreateFeatureclass_management(env.workspace, outfile,"Polyline", infile)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For running this script on a selected set, you can run your search cursor initially set up with a query to define a selected set.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope that helps.&amp;nbsp; Also, next time you post, it would be helpful to include any error messages that may result.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 31 Oct 2012 11:51:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/python-code-error/m-p/500008#M1665</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2012-10-31T11:51:17Z</dc:date>
    </item>
    <item>
      <title>Re: Python code error</title>
      <link>https://community.esri.com/t5/transportation-questions/python-code-error/m-p/500009#M1666</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The following code work on your sample data. In short - you don't need to loop through every point in part's point Array. It's enough to take first point (&lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;"&gt;Array.getObject(0)&lt;/SPAN&gt;&lt;SPAN&gt;) and add it to the end of array.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I didn't introduce Wayne's remarks, so polishing the code is your job;)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You may also need to copy attributes' values from input layer to output.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# Import arcpy module
import arcpy, sys, os, traceback
from arcpy import env

env.overwriteOutput = True
env.workspace = r"C:\tmp\selectedlines.gdb"


# Get the output feature class
infile = r"C:\tmp\selectedlines.gdb\line"
outfile = r"C:\tmp\selectedlines.gdb\testline"

# Identify the geometry field
desc = arcpy.Describe(infile)
shapefieldname = desc.ShapeFieldName
OIDFieldName = desc.OIDFieldName

# Create the output feature class
#arcpy.CreateFeatureclass(path,name,"POLYLINE", infile)
arcpy.CreateFeatureclass_management(os.path.dirname(outfile), os.path.basename(outfile), "Polyline", infile,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "SAME_AS_TEMPLATE","SAME_AS_TEMPLATE",infile)

rows = arcpy.SearchCursor(infile)
cur = arcpy.InsertCursor(outfile)

# Iterate through the rows in the cursor
for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Create the geometry object
&amp;nbsp;&amp;nbsp;&amp;nbsp; feat = row.getValue(shapefieldname)
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Print the current multipoint's ID
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Feature %i:" % row.getValue(desc.OIDFieldName)
&amp;nbsp;&amp;nbsp;&amp;nbsp; partnum = 0

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Step through each part of the feature
&amp;nbsp;&amp;nbsp;&amp;nbsp; for part in feat:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Print the part number
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #print "Part %i:" % partnum

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Create an array of points from part
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pointsArray = feat.getPart(partnum)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Get the first point from Array
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; firstPoint = pointsArray.getObject(0)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Add first point to the end of array to close a line
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pointsArray.add(firstPoint)

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; feat = cur.newRow()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; feat.shape = pointsArray

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Insert the feature
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cur.insertRow(feat)

pointsArray.removeAll()
del cur, rows&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 21:57:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/python-code-error/m-p/500009#M1666</guid>
      <dc:creator>MarcinGasior</dc:creator>
      <dc:date>2021-12-11T21:57:20Z</dc:date>
    </item>
    <item>
      <title>Re: Python code error</title>
      <link>https://community.esri.com/t5/transportation-questions/python-code-error/m-p/500010#M1667</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: Wayne_Whitley&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Ah, that's right, getPart will return an array of point objects, sufficient to pass to the 'new' geometry instead of dealing with coords (which aren't themselves being manipulated).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Good observation, thanks Marcin.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 31 Oct 2012 13:19:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/python-code-error/m-p/500010#M1667</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2012-10-31T13:19:37Z</dc:date>
    </item>
  </channel>
</rss>

