I have some problems adding multiple feature classes (not only a single one) from a geodatabase to a map file in an ArcGIS Pro project and I'm wondering if someone knows of a solution to this. To be able to add more than just one layer from the gdb I've tried to use ListFeatureClasses in order to select all feature classes before using AddDatafromPath. But this doesn't seem to do the trick either.
Here's the script. I've tried several other solutions as well, and while some of them did not return any errors they still did not add the data to the map file.
arcpy.env.workspace = "path to gdb" datasets = arcpy.ListDatasets(feature_type='feature') datasets = [''] + datasets if datasets is not None else  rootPath_aprx = "path to aprx" aprx = arcpy.mp.ArcGISProject(rootPath_aprx+ 'Test.aprx') aprxMap = aprx.listMaps("Map") for ds in datasets: for fc in arcpy.ListFeatureClasses(feature_dataset=ds): path = os.path.join(arcpy.env.workspace, ds, fc) print(path) try: aprxMap.addDataFromPath(test) print("yeah.") except: print("gah.")