Is there any way to use Data Driven Pages to generate shapefiles instead of generating PDF? Because I need to export shapefiles generated with their layout in DWG format. If not, do you have an idea of the procedure that I can follow to achieve this task in a more effcient way?
This will export individual features from a feature class into separate shapefiles based on a name in a field. You will LIKELY need to work with the field names because it will work very differently depending on whether the field is a STRING or some other numeric type etc. Therefore expect to spend some time fiddling with the exact syntax of the WhereClause. Pay particular attention to wrapping the values with quotes for strings or not wrapping them in quotes (for a number). Try the query in ArcMap to see how it is formulated.
For example I had a hyphen in all values and had to replace that with an underscore like this ...
strValue = strValue.replace("-", "_")
You may find similar issues but hopefully this will help.
inFC = r"C:\SOMEFOLDER\SOMESHAPEFILE.shp" # could also be fc in a gdb etc. fld_Species = 'ZoneMod' #My field was ZoneMod; replace this with the field in SOMESHAPEFILE ws_Output = r"C:\SOMEFOLDER\OUTPUT" arcpy.AddMessage("Creating output in " + ws_Output + "\nfrom the " + fld_Species + "\nfield in the " + inFC + " feature class") envString = arcpy.ListEnvironments() arcpy.AddMessage(envString) def ExpIndFeatures(inWorkspace, inShapeFile, inField): arcpy.env.workspace = inWorkspace try: ID_List =  SrchCursor = arcpy.SearchCursor(inShapeFile) rec = SrchCursor.next() while rec: ID_value = rec.getValue(inField) ID_List.append(ID_value) rec = SrchCursor.next() ID_List2 = set(ID_List) ID_List3 = list(ID_List2) n = 0 while (n < len(ID_List3)): ID_value = ID_List3[n] # WhereClause = '"' + str(inField) + '" = ' + str(ID_value) strValue = str(ID_value) WhereClause = str(inField) + ' = \'' + strValue + '\'' fileName = "tmp" + strValue + ".shp" arcpy.MakeFeatureLayer_management(inShapeFile, fileName) arcpy.SelectLayerByAttribute_management(fileName, "NEW_SELECTION", WhereClause) arcpy.CopyFeatures_management(fileName, "output_" + strValue + ".shp") n = n + 1 print "processing code: " + str(n) print "WHATEVERYOUNAMETHIS.py has completed" except: arcpy.AddError(arcpy.GetMessages()) print arcpy.GetMessages()