ExportToPNG Python Toolbox Tool

4015
2
Jump to solution
01-20-2015 08:28 AM
RichardMarlow
New Contributor

Hi All,

I am trying to create a Python toolbox tool to export layers to PNG. I can get this to work fine in the Python window, but when I try to save this as a toolbox script and set the df_export_width and df_export_height settings as GetParameterAsText inputs the tool keeps crashing out when running from ArcToolbox.:

>>> import arcpy

... from arcpy import env

...

... dataFrame = arcpy.GetParameterAsText(0)

... outputPNG = arcpy.GetParameterAsText(1)

... dfWidth = arcpy.GetParameterAsText(2)

... dfHeight = arcpy.GetParameterAsText(3)

...

... mxd = arcpy.mapping.MapDocument("CURRENT")

... df = arcpy.mapping.ListDataFrames(mxd, dataFrame)[0]

... arcpy.mapping.ExportToPNG(mxd, outputPNG, df, df_export_width=dfWidth, df_export_height=dfHeight)

If I run the above but with...

... dfWidth = 1600

... dfHeight = 1200

...it works fine.

Any help would be much aprreciated.

Cheers, Rich

0 Kudos
1 Solution

Accepted Solutions
DanPatterson_Retired
MVP Emeritus

did you convert your getparameterastext stuff back to integers? they are text, that is the purpose of that method

View solution in original post

0 Kudos
2 Replies
DanPatterson_Retired
MVP Emeritus

did you convert your getparameterastext stuff back to integers? they are text, that is the purpose of that method

0 Kudos
RichardMarlow
New Contributor

Thank you Dan - that is what I was missing!

0 Kudos