AnsweredAssumed Answered

Looping and Adding All Features From a File Geodatabase Dataset into Current Map

Question asked by behClevest on May 24, 2017


I need to add all features within a dataset called MainSt in a file geodatabase which is stored at following directory


to current map. using following code I am able to add them one by one but can you please let me know how I can loop and add them dynamically

    mxd = arcpy.mapping.MapDocument("CURRENT")
    df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
    targetGroupLayer = arcpy.mapping.ListLayers(mxd, "Main Streets", df)[0]
    addLayer = arcpy.mapping.Layer(r"C:\Temp\Roads.gdb\MainSt\trace_Fittings")
    arcpy.mapping.AddLayerToGroup(df, targetGroupLayer, addLayer, "BOTTOM")


can you please let me know how to do this?