Sunday, 25 November 2018

arcpy - How do you use folders as input/output parameters


What I want to do is to go into a folder, find a layer file, pull it into an MXD, then export a jpeg in an output folder. Everything is great except I don't know how to set the input/output folders.


state =  arcpy.GetParameterAsText(0)
In_Folder = arcpy.GetParameterAsText(1)
Out_Folder = arcpy.GetParameterAsText(2)


lyrfile_o = arcpy.mapping.Layer(In_Folder + str(state) + "_O.lyr")

lyrfile_d = arcpy.mapping.Layer(In_Folder + str(state) + "_D.lyr")
lyrfile_lane = arcpy.mapping.Layer(In_Folder + str(state) + "_Lanes_.lyr")
lyrfile_poly = arcpy.mapping.Layer(In_Folder + str(state) + "_Lanes_Polys1.lyr")

and I get an error like:


: Object: CreateObject Layer invalid data source>

It's written in a text editor then brought into a toolbox and parameters set, both types as folders, the first one (state) is a string.


Any ideas?




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...