I'm having trouble with the last bit of my script. What I want to do is select a number of features in a SDE layer, then export each feature individually into its own shapefile.I am able to open a searchcursor and go through it record by record however the Select_analysis command just creates an empty shapefile for each record.Any ideas what I'm doing wrong? Thanks,Frank Ogiamien
print "Opening cursor in the local block layer"
cur = gp.SearchCursor("Block_Out_Testing")
row = cur.next()
while row:
try:
rec_id = str(row.OBJECTID)
lic = str(row.FOREST_BC_V_BLOCKS_LICENCE_ID)
cp = str(row.FOREST_BC_V_BLOCKS_PERMIT_ID)
blk = str(row.FOREST_BC_V_BLOCKS_BLOCK_ID)
blk4 = blk.replace("!", "")
blk3 = blk4.replace("-", "_")
blk2 = blk3.replace("/", "_")
outshp = OUTPUT_DIR + "\\" + lic + "\\" + cp + "\\" + blk2 + ".shp"
if not gp.exists(OUTPUT_DIR + "\\" + lic):
os.mkdir(OUTPUT_DIR + "\\" + lic)
if not gp.exists(OUTPUT_DIR + "\\" + lic + "\\" + cp):
os.mkdir(OUTPUT_DIR + "\\" + lic + "\\" + cp)
print "Exporting: " + rec_id + " " + lic + " " + cp + " " + blk
gp.Select_analysis("C:\\Projects\\Block_Export\\Block_Shape_Export.mdb\\Block_Out_Testing", outshp, "\"FOREST_BC1\" = " + "'" + blk + "'")
row = cur.next()
except:
print "an error occurred"
print gp.GetMessages(0)
row = cur.next()