def createDerivedLayer(SourceLayer, UpdateName, DefinitionQuery = ""): """ Creates a new in-memory Layer in the ArcMap Table of Contents derived from an existing Layer on disk or in the ArcMap Table of Contents as referenced by the 'SourceLayer' argument, and pastes the DerivedLayer into the Table of Contents. Optionally applies a Definition Query to the newly Dervied Layer. """ SourceLayer = arcpy.mapping.Layer(str(SourceLayer)) DerivedLayer = SourceLayer DerivedLayer.name = str(UpdateName) if DefinitionQuery: DerivedLayer.definitionQuery = str(DefinitionQuery) arcpy.mapping.AddLayer(df, DerivedLayer, "AUTO_ARRANGE") arcpy.RefreshTOC() arcpy.RefreshActiveView()
Solved! Go to Solution.
rowcount = int(str(arcpy.GetCount_management("DerivedLayer"))) if rowcount > 0: 'we have rows, do something with them! else: 'no rows in the DerivedLayer, I guess exit? return
rowcount = int(str(arcpy.GetCount_management("DerivedLayer"))) if rowcount > 0: 'we have rows, do something with them! else: 'no rows in the DerivedLayer, I guess exit? return
This works on a Feature Layer. See if it will work for you!rowcount = int(str(arcpy.GetCount_management("DerivedLayer"))) if rowcount > 0: 'we have rows, do something with them! else: 'no rows in the DerivedLayer, I guess exit? return