I'm working on a script to automate the conversion of CAD .dwgs of rooms to feature classes, I'm nearing completion and am now working on the second portion of the script (I've seperated it into two modules as the first part takes about an hour to run and the second part should execute MUCH faster). Part of the script involves adding two fields to one layer, and then joining it to another layer.
The problem is, when I execute "arcpy.AddJoin_management" the fields I added aren't in the attribute table. Whats puzzeling is the fields show up when I crate a shapefile from the layer when I perform "arcpy.CopyFeatures_management" before I execute the join.
import arcpy from arcpy import env import os import math # Set the MTolerance to 0.02 arcpy.env.MTolerance = 0.02 # Set overwrite option arcpy.env.overwriteOutput = True #Set Workspace arcpy.env.workspace = "in_memory" #input dataset from part 2 converted_CAD = r"C:\Users\JOE.AWESOME\test_script_output\test.shp" #create a minimum boundary geometry arcpy.MinimumBoundingGeometry_management (converted_CAD, 'bounding_geom', 'RECTANGLE_BY_AREA','', '', 'MBG_FIELDS') #create layers for an attribute join arcpy.MakeFeatureLayer_management (converted_CAD, 'CAD_layer') arcpy.MakeFeatureLayer_management ('bounding_geom', 'bounding_geom_layer') #Add a field to the table for the difference between the Minimum Bounding Geometry and the CAD_layer area arcpy.AddField_management ('CAD_layer', 'area_diffe', 'FLOAT') arcpy.AddField_management ('CAD_layer', 'area_sqM', 'FLOAT') #join the two layers for analysis arcpy.AddJoin_management ('CAD_layer', 'FID', 'bounding_geom_layer', 'ORIG_FID') #calculate the area of the polygons in the CAD_layer arcpy.CalculateField_management ('CAD_layer', 'area_sqM', '!shape.area@squaremeters!', 'PYTHON_9.3') arcpy.CopyFeatures_management ('CAD_layer', r"C:\Users\JOE.AWESOME\test_script_output\join_test.shp")
I've tried changing them to a FLOAT from a DOUBLE, but that didn't change anything. I'm stuck, maybe it's something little. In the words of Michael Bolton, "I always miss some mundane detail."