We have a python script that imports AutoCAD DWG files to SDE feature classes. These DWG files are created by various 3rd parties and are transmitted to us for import. One of the steps in our import process is to create a PRJ file for the DWG. Mostly, this works fine but about 5% of the DWG's have a problem when trying to create the PRJ file. We use arcpy.DefineProjection_management to create the PRJ and it always runs but doesn't always create the PRJ. When it doesn't, no error is thrown. The code just silently keeps going without creating the PRJ. Does anyone know what might be the problem or have similar issues?
Python versions: 2.7 and 3.13.7
Arcpy versions: 10.9.1 and 3.6.4
SDE version: 10.9.1
def project(strFullWorkingFilePath, dblScaleFactor):
try:
# Scale Factor: it gets multiplied by the false northing and easting to move the drawing.
# Use Decimal data type instead of float in spatial ref calculation.
sfi = Decimal(dblScaleFactor)
sf = Decimal(1.0)/Decimal(sfi)
fe_4204 = Decimal(1968500.0) * Decimal(sf)
fn_4204 = Decimal(13123333.33333333) * Decimal(sf)
# Build the coordinate system string that will be stored in the CAD file's PRJ file.
Coordinate_System = "PROJCS['NAD_1983_StatePlane_Texas_South_Central_FIPS_4204_Feet',GEOGCS['GCS_North_American_1983',DATUM['D_North_American_1983',SPHEROID['GRS_1980',6378137.0,298.257222101]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Lambert_Conformal_Conic'],PARAMETER['False_Easting'," + str(fe_4204) + "],PARAMETER['False_Northing'," + str(fn_4204) + "],PARAMETER['Central_Meridian',-99.0],PARAMETER['Scale_Factor'," + str(sf) + "],PARAMETER['Standard_Parallel_1',28.38333333333333],PARAMETER['Standard_Parallel_2',30.28333333333333],PARAMETER['Latitude_Of_Origin',27.83333333333333],UNIT['Foot_US',0.3048006096012192]]"
# Tool: Define Projection creates the correct PRJ file along side the CAD file.
arcpy.DefineProjection_management(strFullWorkingFilePath, Coordinate_System)