reaglebeagle

Get Parameter as Text Issue

Discussion created by reaglebeagle on Aug 8, 2012
Latest reply on Aug 9, 2012 by clthompson
Hi,
I have the strangest thing where my code works fine, then it doesn't. In my tool parameter, I can enter SD, OR, or LA and the code will do an intersect with my DASC layer (which becomes DASC_lyr) and my PDC layer (just for the region San Diego, Los Angeles, or Orange). About 50% of the time, it will work and do what its supposed to. The other times, it says it can't find DASC. I get this error:

<class 'arcgisscripting.ExecuteError'>: Failed to execute. Parameters are not valid.
ERROR 000732: Input Features: Dataset DASC does not exist or is not supported
Failed to execute (MakeFeatureLayer).

So wierd.. Here is what I got

gp.workspace = os.getcwd() + '\\''myData.mdb'
da_pdc_int = os.getcwd() + '\\''myData.mdb\\DA_PDC_INTERSECT'
inputStr = gp.GetParameterAsText(0)
if inputStr == 'SD':
    gp.MakeFeatureLayer_management('DASC', 'DASC_lyr',"[TURF] = 'San Diego' ")
    gp.Intersect_analysis("PDC;DASC_lyr" ,da_pdc_int, "ALL", "", "INPUT")
if inputStr == 'LA':
    gp.MakeFeatureLayer_management('DASC', 'DASC_lyr',"[TURF] = 'Los Angeles' ")
    gp.Intersect_analysis("PDC ;DASC_lyr" ,da_pdc_int, "ALL", "", "INPUT")
if inputStr == 'OR':
    gp.MakeFeatureLayer_management('DASC', 'DASC_lyr',"[TURF] = 'Orange' ")
    gp.Intersect_analysis("PDC ;DASC_lyr" ,da_pdc_int, "ALL", "", "INPUT")
else:
    gp.Intersect_analysis("PDC ;DASC" ,da_pdc_int, "ALL", "", "INPUT")

Outcomes