I have a stand alone script that I am simply trying to get a record count from a layer in an mxd. I continue to get '-1' as the output with a layer that has 1200+ records. The data source is an SDE feature class within a feature dataset. When I try to print the data source I only get the name of the feature dataset and the feature class. I think the issue is because of this? I need to have the complete path seeing as this script will be run by other people on their own machines. Here is the portion of the code that prints the data source and tries to get the count:
import arcpy mxd_path = r'C:\Projects\Test2.mxd' mxd = arcpy.mapping.MapDocument(mxd_path) df = arcpy.mapping.ListDataFrames(mxd) layer = arcpy.mapping.ListLayers(mxd, 'Test Boundary', df) print layer.dataSource print int(arcpy.GetCount_management(layer.getOutput(0))
The first print statement returns
The second print statement returns
The path and names of the mxd and layer are correct and exist. I think this is really weird that it won't include the sde connection file path with the layer.dataSource? I haven't found other answers to this specific problem I saw similar threads here
However this only indicates using the describe with layer.dataSource. if I try to run any arcpy/geoprocessing on the layer it says this is not a valid parameter. For example I can't create a feature layer with MakeFeatureLayer_management with the layer returned in the stand alone script. I can run it in the Python command window successfully but unfortunately need to solve it for the stand alone script per my situation. Anyone seen this same issue of not returning the full path of the layer's data source?