Hello, I'm having some struggles with my script. In my model, I set the first parameter to be the map to convert.
Solved! Go to Solution.
Here is the solution:
import arcpy
aprx = arcpy.mp.ArcGISProject("CURRENT")
mapName = arcpy.GetParameterAsText(0)
map1 = aprx.listMaps(mapName)[0]
arcpy.AddMessage(map1.name)
To be clear, the parameter data type in the tool properties is "Map"
When I just say "arcpy.AddMessage(map1)" there are no errors and the message is the name of the map.
When I try "arcpy.AddMessage(type(map1)) is says "<class 'geoprocessing value object'>"
So I have figured out that the map class in the arcpy mapping module is not the same as the map data type, but that's as far as I've been able to get with the documentation. Confirmation that my approach is wrong, but so far no idea on next steps.
Here is the solution:
import arcpy
aprx = arcpy.mp.ArcGISProject("CURRENT")
mapName = arcpy.GetParameterAsText(0)
map1 = aprx.listMaps(mapName)[0]
arcpy.AddMessage(map1.name)