AnsweredAssumed Answered

How to dynamically create an empty layer file (for use as a group layer)?

Question asked by dmarquardt on Aug 20, 2015
Latest reply on Aug 21, 2015 by msavage2



I'm trying to create an mxd that can dynamically create and name group layers, and populate them with various feature layers.  I've seen some examples of how to do this, such as : How to add a new Group Layer using arcpy


The basics seem to be: reference an empty layer:

  groupLayer = arcpy.mapping.Layer(r"D:\Test\GroupTest.lyr")

Add it to the map:

  arcpy.mapping.AddLayer(df, groupLayer, "BOTTOM")

  listedGroupLayer = arcpy.mapping.ListLayers(mxd, "GroupTest", df)[0]

Then add some layer to it;

  addLayer = arcpy.mapping.layer(r"D\Test\Rivers.lyr")

  arcpy.mapping.AddLayerToGroup(df, listedGroupLayer, addLayer, "BOTTOM")[0]



I'm getting stuck on the first step: I need to dynamically create an empty layer file (based off of group layer names in a spreadsheet), before referencing it.


Any examples of how to create an empty layer file (rather than reference one), within python? 


Thank you,