AnsweredAssumed Answered

How can I add a feature class (shapefile) to the current map doc using arcpy.mp (Python 3)?

Question asked by djmirabito on Aug 15, 2017
Latest reply on Sep 21, 2017 by cmwrenn3

I am writing a script tool to be used in ArcGIS Pro. The script tool performs some geoprocessing and saves its results to a folder. What I would like to do is add the results from disk back to the current map document. Basically, I am looking for the equivalent to the below for arcpy.mp in Python 3:

 

import arcpyfrom arcpy import env # get the map documentmxd = arcpy.mapping.MapDocument("CURRENT")# get the data framedf = arcpy.mapping.ListDataFrames(mxd,"*")[0]# create a new layernewlayer = arcpy.mapping.Layer(path_to_shapefile_or_feature_class)# add the layer to the map at the bottom of the TOC in data frame 0arcpy.mapping.AddLayer(df, newlayer,"BOTTOM")

I need to add a shapefile, not a .lyrx file. Is there a way to do this with arcpy.mp? I have been looking everywhere.

Outcomes