I am trying to simply bring in a Feature Class from a File Geodatabase into an OPEN arcPro project
Any thoughts?
Error: AttributeError: 'NoneType' object has no attribute 'addLayer'
import arcpy
import fileinput
import string
import os
from arcpy import env
# FILE GDB where the feature class to bring in resides
arcpy.env.workspace = r"C:\\Users\\ImportFeatureClass_Pro\\ProToolTest.gdb"
# ArcPRO Project Location of the OPEN ArcPro Project
aprx = arcpy.mp.ArcGISProject(r"C:\\Users\\ImportFeatureClass_Pro\\ImportFeatureClass_Pro.aprx")
aprxMap = aprx.activeMap
# The Feature Class from File GDB that I want brought into the OPEN ArcPro Project
file_location = r"C:\\Users\\ImportFeatureClass_Pro\\ProToolTest.gdb\MasonCliiped"
aprxMap.addLayer(file_location, "TOP")
I think is not possible lyrx normally in to Gdb?
Which of the three options are you using to run your code?
activemap
This property is designed to be run from within the application using a script tool, the Python window, or a Notebook. If a script is run outside of the application, a value of None will always be returned.
ArcGISProject—ArcGIS Pro | Documentation
addLayer() isn't great since it calls for a layer file or a pre-existing.
Try addDataFromPath() instead to make a new layer from scratch.