Trying the following:
1. Add polygon Layer from gpkg and rename Layer
2. Add Line Layer from gpkg and rename Layer
3. Run Model with Parameters set to added Layers
4. Remove Layers.
Then repeat for the next geocell (many many more)
Problem.
All outputs are the same as the first Layers added. Even though the Layers are removed and new Layers added and I clean out the ScratchGDB all outputs are the same as the first one. If I don't remove the Layers and just keep adding new Layers it works ok. BUT I have hundreds of geopackages and the project gets bloated and ARCGIs runs very very slowly (10x slower) so I really need to remove Layers after each time the Model is run.
Help!
import arcpy
from WorldFPatbx.DeleteScratchGDB import DeleteScratchGDB
from WorldFPatbx.ModelSub01 import ModelSub01
aprx = arcpy.mp.ArcGISProject('CURRENT')
current_map = aprx.activeMap
def ModelMaster_9_3_45__135():
arcpy.AddMessage("Starting Building_9_3_45__135")
current_map.addDataFromPath("D:\\ESRI-Daylight\\NCERTS_1.0\\World_9_3\\World_9_3_45_-135.gpkg\\main.multipolygons")
layer = current_map.listLayers("main.multipolygons")[0]
layer.name = "multipolygons_45__135"
polyLyr=layer
current_map.addDataFromPath("D:\\ESRI-Daylight\\NCERTS_1.0\\World_9_3\\World_9_3_45_-135.gpkg\\main.lines")
layer = current_map.listLayers("main.lines")[0]
layer.name = "lines_45__135"
lineLyr=layer
main_multipolygons = "multipolygons_45__135"
main_lines = "lines_45__135"
Footprints_gpkg = "D:\\ESRI-Daylight\\NCERTS_1.0\\World_9_3\\BuildingFP\\Footprints_9_3_45__135.gpkg"
Buildings = "D:\\ESRI-Daylight\\NCERTS_1.0\\World_9_3\\BuildingFP\\Footprints_9_3_45__135.gpkg\\Buildings"
ModelSub01(Input_Lines=main_lines, Input_polygons=main_multipolygons, FPGeopackage=Footprints_gpkg, GPFootprints=Buildings)
DeleteScratchGDB()
current_map.removeLayer(polyLyr)
current_map.removeLayer(lineLyr)
arcpy.AddMessage("Building_9_3_45__135 Finished")
with arcpy.EnvManager(scratchWorkspace="C:\\ArcGISProjectNXT\\WorldFP\\WorldFP.gdb", workspace="C:\\ArcGISProjectNXT\\WorldFP\\WorldFP.gdb"):
ModelMaster_9_3_45__135()
def ModelMaster_9_3_45__134():
arcpy.AddMessage("Starting Building_9_3_45__134")
current_map.addDataFromPath("D:\\ESRI-Daylight\\NCERTS_1.0\\World_9_3\\World_9_3_45_-134.gpkg\\main.multipolygons")
layer = current_map.listLayers("main.multipolygons")[0]
layer.name = "multipolygons_45__134"
polyLyr=layer
current_map.addDataFromPath("D:\\ESRI-Daylight\\NCERTS_1.0\\World_9_3\\World_9_3_45_-134.gpkg\\main.lines")
layer = current_map.listLayers("main.lines")[0]
layer.name = "lines_45__134"
lineLyr=layer
main_multipolygons = "multipolygons_45__134"
main_lines = "lines_45__134"
Footprints_gpkg = "D:\\ESRI-Daylight\\NCERTS_1.0\\World_9_3\\BuildingFP\\Footprints_9_3_45__134.gpkg"
Buildings = "D:\\ESRI-Daylight\\NCERTS_1.0\\World_9_3\\BuildingFP\\Footprints_9_3_45__134.gpkg\\Buildings"
ModelSub01(Input_Lines=main_lines, Input_polygons=main_multipolygons, FPGeopackage=Footprints_gpkg, GPFootprints=Buildings)
DeleteScratchGDB()
current_map.removeLayer(polyLyr)
current_map.removeLayer(lineLyr)
arcpy.AddMessage("Building_9_3_45__134 Finished")
with arcpy.EnvManager(scratchWorkspace="C:\\ArcGISProjectNXT\\WorldFP\\WorldFP.gdb", workspace="C:\\ArcGISProjectNXT\\WorldFP\\WorldFP.gdb"):
ModelMaster_9_3_45__134()