Create MXD for each FC row

Discussion created by alex92190 on May 23, 2013
Latest reply on Jun 3, 2013 by rzufelt
Hi all,
I have FC with 125 rows, and I would like to make a separate MXD for each single attribute I have got . In this case I will be using the FID for my loop. My scripts is not working as I wish. Do anyone have an idea how to automate this process? Thank you

Attach is my script:

import arcpy, os
from arcpy import env
#Overwrite features
arcpy.env.overwriteOutput = True

shape = r"K:\Working\Alex_Gole\cult.shp"
output = r"K:\Working\Alex_Gole\test"
layer = r"K:\Working\Alex_Gole\letter_lyr_new"
rows = arcpy.SearchCursor(shape, "", "", "FID", "FID")
mxd = arcpy.mapping.MapDocument(r"K:\Working\Alex_Gole\Try.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
inset = arcpy.mapping.ListDataFrames(mxd, "New Data Frame")[0]

#For each work order:
for row in rows:
    # Create a clause to select only the current record
    whereclause = '"FID" = ' + str(row.FID)
    # Create a feature layer from the current row only
    arcpy.MakeFeatureLayer_management(shape, layer, whereclause)
    #Create feature class for each point
    arcpy.CopyFeatures_management(layer, r"K:\Working\Alex_Gole\test\try.shp" + str(row.FID))
    newMxd = "Fig1_" + row.Name + ".mxd"
    pathNewMxd = r'K:\Working\Alex_Gole\test\\' + newMxd
    if os.path.exists(pathNewMxd):
        #copy template and name file "Fig1_Task_WO_Name_NuPoles"
                        + newMxd)
        print "Saving " + newMxd
print "All done."

del mxd