christi_nelson

Creating script tool from python - cant get parameter/data type to work correctly.

Discussion created by christi_nelson on Jul 1, 2013
Latest reply on Jul 2, 2013 by stacyrendall
Hi all,

My script runs fine in PythonWin and in the ArcGIS Python Window, so the code is good.  But for some reason I can't figure out how to set the parameters in the Add Script Wizard (ArcGIS 10.0 SP 5).  My script essentially creates data driven pages using a parcel as the index grid.  Each map is then exported to a pdf.  In my script, the output path (outpath) and the output folder (outfolder) are combined in the CreateFolder_management dialogue (to create the output folder if it does not exist).

My outpath is "C:\\" and my outfolder is "temp\\" to create "C:\\temp\\" when joined together.

In the Add Script Wizard I have defined the Display Names and Data Types as follows:

Display Name:                                 Display Type:
Output PDF file path:                          Folder             (this is not allowing me to browse to just "C:\\")
Output PDF file folder:                        Folder            

My question is: what Display Type do I need to set for the Output PDF file path, so that it will take an input of only C:\\ (and not some subfolder under C:\\)?


A snippet of my code is below and an attachment image of my Add Script Wizard is attached.
[CODE] #Check for existance of the output data before running the export tool.
                #Export to PDF
                outpath = "C:\\" #arcpy.GetParameterAsText(2)
                outfolder = "temp\\" #arcpy.GetParameterAsText(3)
                pdfLocation =  os.path.join(outpath, outfolder) #"C:\\temp\\"

                #print "pdfLocation:  " + pdfLocation
               
                pdfName = pdfLocation + APN + '.pdf'

                #print "pdfName:  " + pdfName

                if arcpy.Exists(pdfLocation):
                        pass
                        print "Folder Exists"
                else:
                        print r"Folder does not exist. Creating Folder"
                        arcpy.CreateFolder_management(outpath, outfolder)
                       
                if arcpy.Exists(pdfName):
                    arcpy.Delete_management(pdfName)

               CODE]

Thanks,
Christi

Attachments

Outcomes