Hello All,
I am new to Python coding, but somehow managed to put together a simple code by looking at others code available online.
What I want to achieve: A user should select a custom designed template MXD which initially will be loaded only with basemap layers. Then the user will add a raster file from local path to the MXD. User will Type in the Name of the Raster Layer to be displayed in TOC. Then the code will export the MXD to a PDF file.
Below mentioned code works well when I run it in the same MXD's Python command window.
mxdPath = r"C:\MXD.mxd" #Paratmeter 1
... rasterPath = r"C:\Raster.tft" #Paratmeter 2
... mxd = arcpy.mapping.MapDocument(mxdPath)
... df = arcpy.mapping.ListDataFrames(mxd)[0]
... result = arcpy.MakeRasterLayer_management(rasterPath,"Raster Layer Name") #Parameter 3
... layer = result.getOutput(0)
... arcpy.mapping.AddLayer(df,layer, 'AUTO_ARRANGE')
... arcpy.mapping.ExportToPDF(mxd,r"C:\Test.pdf") #Parameter 4
I have two queries, and will really appreciate if someone can guide me in the right direction.
1. How can I let user update the 4 parameters in the code without opening the code
I have seen online add parameters while adding script in the tool box but not sure how to pass them in the code.
Required Parameters
- Input Template MXD Path
- Input Raster File Path
- Input Type Raster File Name (To be entered by the User to update in TOC)
- Output PDF path
2. Is it possible to rename the PDF as per the Raster File Name the user types in the parameter 3
Will really appreciate any help and pointers in the right direction.
Thanks and Regards,
Ajinkya