With Python, how do I get either the MakeXYEventLayer_management or the MakeFeatureLayer_management layer that is temporarily created added to ArcMap automatically after the tool is run, without using arcpy.mapping?


Add an output parameter of type Feature Layer to your tool. Set its value to the name of the XY Layer you make with the tool at the end of your script. This lets the geoprocessing framework know that you really meant to make that layer permanent (and not just as intermediate data) and to add it to the table of contents.

  • Thanks. I got it figured out. Is there anything wrong with adding features to ArcMap when they are in memory? I notice when I go to the data sources tab, it says the layer is from GPInMemoryWorkspace:{...}. Is there anything technically wrong with doing this, like is it bad form? – ianbroad Sep 18 '13 at 22:40
  • Just be aware that they won't persist to disk, so if you save out an MXD that has layers with in memory feature classes they'll be empty the next time you open the document. In memory feature classes are super nice in that they're really fast since Arc* doesn't have to touch the disk/network to access them. – Jason Scheirer Sep 18 '13 at 22:44
  • Yeah, this is definitely a layer that doesn't need to be saved, we just need to see it once. I noticed that I can't add arcpy.Delete_management(layer) to the end of my script because obviously the layer I add to ArcMap is then empty. This doesn't cause some type of memory issue by not deleting it, right? Just when ArcMap closes, the memory is then removed? – ianbroad Sep 18 '13 at 22:46
  • Yeah, the memory gets freed when you manually delete the layer from the table of contents or when ArcMap closes. – Jason Scheirer Sep 18 '13 at 22:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.