Import arcpy
arcpy.TableToTable_conversion("MyLayer",r"C:\Output","Mytable.dbf")
I suggest reviewing ArcGIS Online help.
Here is your test example modified to import a "utility" module within the main script and call a function using the parameters read in by the script tool:
CopyFeaturesTool.py - Script tool that reads in parameters and calls a function in another module
import CopyFeaturesUtility
import arcpy
inputFC = arcpy.GetParameterAsText(0)
outputFCName = arcpy.GetParameterAsText(1)
CopyFeaturesUtility.copyFeaturesToTempGDB(inputFC, outputFCName)
CopyFeaturesUtility.py - Module that has a single function copyFeaturesToTempGDB
. Can either be imported or run standalone. If run standalone the code under if __name__ == '__main__'
is run.
import arcpy
import os
def copyFeaturesToTempGDB(inputFeatures, outputName):
"""Copies the input features to a temporary file geodatabase.
inputFeatures: The input feature class or layer.
outputName: The name to give the output feature class."""
tempGDB = r"c:\temp\test.gdb"
newFC = os.path.join(tempGDB, outputName)
arcpy.env.overwriteOutput = True
arcpy.CopyFeatures_management(inputFeatures, newFC)
if __name__ == '__main__':
inputFC = r"c:\temp\test.gdb\test"
outputFCName = "testCopy"
copyFeaturesToTempGDB(inputFC, outputFCName)
I think you'll find this modular approach to be much more efficient and logical once you've gotten used to it. The Modules section in the standard Python tutorial is also a good resource for understanding how importing works.
For more arcpy-specific examples take a look at the built-in scripts in your C:\Program Files\ArcGIS\Desktop10.0\ArcToolbox\Scripts
folder.
Best Answer
Built in to arcpy is a series of classes for making graphs, it may be what you need.
What of matplotlib isn't working? I know the TK parts of the UI don't play nice in the UI, but exporting to an image file and using
os.startfile
should work, or marking the tool to run out of process.