Programmatically Creating a Feature Class

Discussion created by lozierd on Dec 9, 2010
Latest reply on Dec 14, 2010 by lozierd
I'm trying to programmatically create a feature class by doing the following:

Calling CreateFeatureclass_management() to create the feature class

Calling AddField_management() in a loop to add all of the fields. (About 50 in total)

Calling DeleteField_management() to remove the default 'Id' field created by the CreateFeatureclass method.

When I run the script with the above code from the command line it runs 'relatively' fast (takes about 5 secs) but, once I bind the script to an ArcToolbox Tool (no changes to the script) it takes significantly longer (3min 20sec).

One thing that might point as to why its taking so long is that if I add the line 'arcpy.env.workspace="c:/workspace"' it speeds up some (1min 10sec) but still nowhere near the command line.

Also in general is there a better/faster way to programmatically create a feature class from scratch? I can't use the template parameter to the createFeatureclass_management method.