<?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 Remeasure routes in field calculator using Python in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/remeasure-routes-in-field-calculator-using-python/m-p/97729#M7595</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Is it possible to remeasure routes in ArcMap 10 using Python in the field calculator? In 9.3 we used the following vbscript to remeasure routes and it works fine. If I understand correctly, in ArcMap 10, vbscript does not work on geometry any more.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="font-style:italic;"&gt;dim pms as imsegmentation&lt;BR /&gt;dim pLine as IPolyline&lt;BR /&gt;set pLine = [SHAPE]&lt;BR /&gt;set pms = [SHAPE]&lt;BR /&gt;pms.setandinterpolatemsbetween 0, pLine.length * .0006214&lt;BR /&gt;dim pg as igeometry&lt;BR /&gt;set pg = pms&lt;BR /&gt;&lt;BR /&gt;__esri_field_calculator_splitter__&lt;BR /&gt;pg&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 07 Jul 2011 17:37:06 GMT</pubDate>
    <dc:creator>PaulReichart</dc:creator>
    <dc:date>2011-07-07T17:37:06Z</dc:date>
    <item>
      <title>Remeasure routes in field calculator using Python</title>
      <link>https://community.esri.com/t5/python-questions/remeasure-routes-in-field-calculator-using-python/m-p/97729#M7595</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Is it possible to remeasure routes in ArcMap 10 using Python in the field calculator? In 9.3 we used the following vbscript to remeasure routes and it works fine. If I understand correctly, in ArcMap 10, vbscript does not work on geometry any more.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="font-style:italic;"&gt;dim pms as imsegmentation&lt;BR /&gt;dim pLine as IPolyline&lt;BR /&gt;set pLine = [SHAPE]&lt;BR /&gt;set pms = [SHAPE]&lt;BR /&gt;pms.setandinterpolatemsbetween 0, pLine.length * .0006214&lt;BR /&gt;dim pg as igeometry&lt;BR /&gt;set pg = pms&lt;BR /&gt;&lt;BR /&gt;__esri_field_calculator_splitter__&lt;BR /&gt;pg&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jul 2011 17:37:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/remeasure-routes-in-field-calculator-using-python/m-p/97729#M7595</guid>
      <dc:creator>PaulReichart</dc:creator>
      <dc:date>2011-07-07T17:37:06Z</dc:date>
    </item>
    <item>
      <title>Re: Remeasure routes in field calculator using Python</title>
      <link>https://community.esri.com/t5/python-questions/remeasure-routes-in-field-calculator-using-python/m-p/97730#M7596</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I do not think it is possible to remeasure routes via the field calculator using python.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However, you could use a script similar to the following to recalculate m values for an existing route feature class.&amp;nbsp; I would change the reference to the feature class and to/from fields and run it in IDLE or PythonWin.&amp;nbsp; It simulates the functionality of the setandinterpolatemsbetween arcobjects command.&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.env.overwriteOutput=1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;inFC = r'C:\GIS\IncidentData\November\982292_Setandinterpolatemsbetween\test.gdb\routes_w_MPs' #Update path to the feature class&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;toField = "BEGMP1" #Update name of the To Measure Field&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;fromField = "ENDMP1" #Update name of the From Measure Field&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;desc = arcpy.Describe(inFC)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;shapeField = desc.shapeFieldName&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;oidField = desc.OIDFieldName&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;oidQueryName = arcpy.AddFieldDelimiters(inFC, oidField)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;g = arcpy.Geometry()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#Create update cursor on input feature class&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;rows = arcpy.UpdateCursor(inFC)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#Make feature layer from input feature class&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.MakeFeatureLayer_management(inFC, "featureLayer")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#loop through rows in feature layer and select each OID&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for row in rows:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management("featureLayer", "New_Selection", oidQueryName + "=" + str(row.getValue(oidField)))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #create geometry object from each feature row&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; geomList = arcpy.CreateRoutes_lr("featureLayer", toField, g, "TWO_FIELDS", fromField, toField)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #update shape field for input feature class for each row (replace M values)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.setValue(shapeField, geomList[0])&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.updateRow(row)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.Delete_management("featureLayer")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;del row, rows&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Many thanks to Chris F. in Redlands for creating this.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Nov 2011 12:12:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/remeasure-routes-in-field-calculator-using-python/m-p/97730#M7596</guid>
      <dc:creator>JacobPetrosky</dc:creator>
      <dc:date>2011-11-09T12:12:05Z</dc:date>
    </item>
    <item>
      <title>Re: Remeasure routes in field calculator using Python</title>
      <link>https://community.esri.com/t5/python-questions/remeasure-routes-in-field-calculator-using-python/m-p/97731#M7597</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Slight modification to script below:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.env.overwriteOutput=1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;inFC = r"C:\GIS\IncidentData\November\982292_Setandinterpolatemsbetween\UserData\PwkTransportationFDSCopyNovember2011.gdb\RouteCopySubsetNov2" #Update path to the feature class&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;toField = "MILEMARKER_END" #Update name of the To Measure Field&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;fromField = "MILEMARKER_BEGIN" #Update name of the From Measure Field&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;routeID = "ROUTEID" #Update name of Route ID field&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;desc = arcpy.Describe(inFC)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;shapeField = desc.shapeFieldName&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;print shapeField&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;oidField = desc.OIDFieldName&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;print oidField&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;oidQueryName = arcpy.AddFieldDelimiters(inFC, oidField)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;g = arcpy.Geometry()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#Create update cursor on input feature class&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;rows = arcpy.UpdateCursor(inFC)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#Make feature layer from input feature class&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.MakeFeatureLayer_management(inFC, "featureLayer")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#loop through rows in feature layer and select each OID&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for row in rows:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management("featureLayer", "New_Selection", oidQueryName + "=" + str(row.getValue(oidField)))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #create geometry object from each feature row&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; geomList = arcpy.CreateRoutes_lr("featureLayer", routeID, g, "TWO_FIELDS", fromField, toField)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #update shape field for input feature class for each row (replace M values)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.setValue(shapeField, geomList[0])&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.updateRow(row)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.Delete_management("featureLayer")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;del row, rows&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Nov 2011 20:17:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/remeasure-routes-in-field-calculator-using-python/m-p/97731#M7597</guid>
      <dc:creator>JacobPetrosky</dc:creator>
      <dc:date>2011-11-14T20:17:56Z</dc:date>
    </item>
  </channel>
</rss>

