Posted the below at forum post 34274. I do not think it is possible to remeasure routes via the field calculator using python or VBA.However, you could use a script similar to the following to recalculate m values for an existing route feature class. I would change the reference to the feature class and to/from fields and run it in IDLE or PythonWin. It simulates the functionality of the setandinterpolatemsbetween arcobjects command.import arcpyarcpy.env.overwriteOutput=1inFC = r'C:\GIS\IncidentData\November\982292_Setandinterpolatemsbetween\test.gdb\routes_w_MPs' #Update path to the feature classtoField = "BEGMP1" #Update name of the To Measure FieldfromField = "ENDMP1" #Update name of the From Measure Fielddesc = arcpy.Describe(inFC)shapeField = desc.shapeFieldNameoidField = desc.OIDFieldNameoidQueryName = arcpy.AddFieldDelimiters(inFC, oidField)g = arcpy.Geometry()#Create update cursor on input feature classrows = arcpy.UpdateCursor(inFC)#Make feature layer from input feature classarcpy.MakeFeatureLayer_management(inFC, "featureLayer")#loop through rows in feature layer and select each OIDfor row in rows:arcpy.SelectLayerByAttribute_management("featureLayer", "New_Selection", oidQueryName + "=" + str(row.getValue(oidField)))#create geometry object from each feature rowgeomList = arcpy.CreateRoutes_lr("featureLayer", toField, g, "TWO_FIELDS", fromField, toField)#update shape field for input feature class for each row (replace M values)row.setValue(shapeField, geomList[0])rows.updateRow(row)arcpy.Delete_management("featureLayer")del row, rowsMany thanks to Chris F. in Redlands for creating this.
Membros conectados podem postar, seguir atualizações e mais. Novo aqui? Registre uma conta gratuita.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.