Mainly the two types of feature classes we will be creating are either a shapefile or a layer in a file geodatabase. It's always going to be a file on the user's machine. No versioning or SDE.I'm not setting a scratch workspace as far as I know. At least not in the python code.Im using ArcMap/ArcDesktop 10.0 Build 2414. No service packs.I can't use the template because I'm getting the list of fields from a service my python code calls and the fields can be different for every call so I don't have a predetermined format to base a template off of.Here is some test code that replicates the issue. I had to hand type this since the machine I'm working on doesn't have internet access so please excuse any typos. It runs on the work machine.
import arcpy
import time
fc_workspace = "c:/test"
fc_name = "test.shp"
fc_fields = (
("a", "TEXT", None, None, 50, "", "NULLABLE", "NON_REQUIRED"),
("b", "LONG", 8, None, None, "", "NULLABLE", "NON_REQUIRED"),
("c", "SHORT", 4, None, None, "", "NULLABLE", "NON_REQUIRED"),
("d", "DOUBLE", 11, 8, None, "", "NULLABLE", "NON_REQUIRED"),
("e", "FLOAT", 5, 2, None, "", "NULLABLE", "NON_REQUIRED"),
("f", "DATE", None, None, None, "", "NULLABLE", "NON_REQUIRED")
)
arcpy.env.workspace = fc_workspace
total_start = time.clock()
start = time.clock()
fc = arcpy.CreateFeatureclass_management(fc_workspace, fc_name, "POINT", spatial_reference="c:/Program Files/ArcGIS/Desktop10.0/Coordinate Systems/Geographic Coordinate Systems/World/WGS 1984.prj")
end = time.clock()
arcpy.AddMessage("Create Feature Class %.3f" % (end - start))
start = time.clock()
for fc_field in fc_fields:
arcpy.AddField_management(fc, *fc_field)
end = time.clock()
arcpy.AddMessage("Create Fields %.3f" % (end - start))
start = time.clock()
arcpy.DeleteField_management(fc, "Id")
end = time.clock()
arcpy.AddMessage("Delete Id Field %.3f" % (end - start))
total_end = time.clock()
arcpy.AddMessage("Total %.3f" % (total_end - total_start))
Output when I run it just as a regular python script:
Create Feature Class 0.313
Create Fields 0.313
Delete Id Field 0.044
Total 0.670
Output when I bind the script to a ArcToolbox Tool. I just create a standard script tool with no parameters.
Executing: testcreatefc
Start Time: Mon Dec 13 19:42:04 2010
Running script testcreatefc...
Create Feature Class 0.628
Create Fields 2.713
Delete Id Field 0.627
Total 3.968
Completed script testcreatefc...
Succeeded at Mon Dec 13 19:42:09 2010
(Elapsed Time: 5.00 seconds)