frankv3

ArcCatalog crashes running script

Discussion created by frankv3 on Jun 2, 2011
Latest reply on Jun 2, 2011 by frankv3
when the following script is run at the python prompt ArcCatalog crashes (ENDS ALTOGETHER) during the second iteration of the for loop at the line arcpy.AddField_management(AnnoPoint, "ALTKEY", "LONG", "", "", "", "", "NULLABLE", "NON_REQUIRED", "") up until then it runs fine, is there something i can do to stop it from crashing?

## Import standard modules
import sys, os

## Set the necessary product code
import arcinfo


## Import arcpy module and environment module
import arcpy
from arcpy import env

Output_Database = arcpy.GetParameterAsText(0)
if Output_Database == '#' or not Output_Database:
    Output_Database = "C:\\WorkSpace\\Bldg_Footprints\\BLDG_Footprints_2011.gdb"

## Overwrite pre-existing files
arcpy.env.overwriteOutput = True

## Set a directory with CAD data
DXF_Directory = arcpy.GetParameterAsText(0)
if DXF_Directory == '#' or not DXF_Directory:
    DXF_Directory = "C:\\WorkSpace\\Bldg_Footprints\\NBHD_0592"

## Set a workspace
arcpy.env.workspace = DXF_Directory

try: 
  for InDXF in arcpy.ListDatasets("",""):
    
    ## Set the ALTKEY
    NameStop = InDXF.rfind(".")
    AltNum = str(InDXF[0:NameStop])
    
    ## Convert CAD to Geodatabase
    arcpy.CADToGeodatabase_conversion(InDXF, Output_Database, "OutDXF", "2400", "NAD_1983_HARN_StatePlane_Florida_East_FIPS_0901_Feet")

    ## Make a feature layer of the Polyline and Annotation features
    arcpy.MakeFeatureLayer_management("C:\\WorkSpace\\Bldg_Footprints\\BLDG_Footprints_2011.gdb\\OutDXF\\Polyline", "Polyline_Layer)    arcpy.MakeFeatureLayer_management("C:\\WorkSpace\\Bldg_Footprints\\BLDG_Footprints_2011.gdb\\OutDXF\\Annotation", "Annotation_Layer")
  
    ## Make the point features from annotation to be used for the Bldg polygon attributes
    AnnoPoint = r"%s/OutDXF/AnnoPoint"%(Output_Database)
    arcpy.FeatureToPoint_management("Annotation_Layer", AnnoPoint, "INSIDE")

    ##### !!! THIS IS WHERE IT CRASHES AFTER THE FIRST ITERATION !!!

    arcpy.AddField_management(AnnoPoint, "ALTKEY", "LONG", "", "", "", "", "NULLABLE", "NON_REQUIRED", "")
    arcpy.AddField_management(AnnoPoint, "BLDG_CODE", "TEXT", "", "", "3", "", "NULLABLE", "NON_REQUIRED", "")
    arcpy.AddField_management(AnnoPoint, "SITUS", "TEXT", "", "", "50", "", "NULLABLE", "NON_REQUIRED", "")
    arcpy.CalculateField_management(AnnoPoint, "BLDG_CODE", "!TextString![1:4]", "PYTHON_9.3", "")
    arcpy.DeleteField_management(AnnoPoint, "TextString")
    arcpy.DeleteField_management(AnnoPoint, "ORIG_FID")

    ## Create the Bldg Footprint polygon
    OutPoly = r"%s\Out_Bldg\Bldg_%s"%(Output_Database,AltNum)
    arcpy.FeatureToPolygon_management("Polyline_Layer", OutPoly, ".05 Feet", "ATTRIBUTES", AnnoPoint)
    arcpy.CalculateField_management(OutPoly, "ALTKEY", AltNum, "PYTHON_9.3", "")
except:
   arcpy.GetMessages()

Outcomes