import arcpy from arcpy import env env.workspace = r"C:\temp\python" mxd = arcpy.mapping.MapDocument("CURRENT") df = arcpy.mapping.ListDataFrames(mxd)[0] lstFCs = arcpy.ListFeatureClasses("*.shp") for fc in lstFCs: arcpy.MakeFeatureLayer_management(fc, "fc") addLayer = arcpy.mapping.Layer("fc") lyr = arcpy.mapping.Layer("fc") lyr.name = fc.split(".")[0] arcpy.RefreshTOC()
mxd = arcpy.mapping.MapDocument("Current") df = arcpy.mapping.ListDataFrames(mxd,"*")[0] newlayer = arcpy.mapping.Layer("C:\pathname\detentio.shp") arcpy.mapping.AddLayer(df, newlayer,"TOP") arcpy.AddField_management ("detentio", "Date_Txt", "TEXT","","",10,"Date_Txt","NULLABLE","NON_REQUIRED","") arcpy.CalculateField_management("detentio","Date_Txt","[Date_Visit]","VB","#") arcpy.ConvertTimeField_management("detentio","Date_Txt","MM/dd/yyyy;1033;;","Date_Mod","TEXT","yyMMdd;1033;;") arcpy.DeleteField_management("detentio","Date_Txt") arcpy.AddField_management ("detentio", "PhotoName", "TEXT","","",40,"PhotoName","NULLABLE","NON_REQUIRED","") arcpy.CalculateField_management ("detentio", "PhotoName","[Date_Mod]& Chr(95) & right([photo],10)","VB") arcpy.AddField_management ("detentio", "PhotoPath", "TEXT","","",200,"PhotoPath","NULLABLE","NON_REQUIRED","") arcpy.CalculateField_management ("detentio", "PhotoPath",'"V:\newpathname\\"&[PhotoName]',"VB") arcpy.DeleteField_management("detentio",["PhotoName"]) arcpy.DeleteField_management("detentio",["photo"]) from arcpy import env env.workspace = "C:\pathname" fc = "detentio" rows = arcpy.SearchCursor("detentio", "FID = 1") for row in rows: time = row.Date_Mod del row, rows arcpy.DeleteField_management("detentio",["Date_Mod"]) arcpy.Rename_management("detentio.shp", "detentio" + "_" + time, "ShapeFile") mxd = arcpy.mapping.MapDocument("Current") for df in arcpy.mapping.ListDataFrames(mxd): for lyr in arcpy.mapping.ListLayers(mxd, "", df): if lyr.name.lower() == "detentio": arcpy.mapping.RemoveLayer(df, lyr) print "Processing Complete."
shapefile = r"C:\temp\Airports.shp" mxd = arcpy.mapping.MapDocument("CURRENT") df = arcpy.mapping.ListDataFrames(mxd)[0] arcpy.MakeFeatureLayer_management(shapefile, "Airports") arcpy.mapping.AddLayer(df, shapefile, "AUTO_ARRANGE")
rows = arcpy.SearchCursor(fc, "OBJECTID = 1") for row in rows: time = row.Time del row, rows arcpy.Rename_management(fc, time)
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.