I could not find a way to access an ArcScene document (.sxd) using python either. The best approach I found was to copy your group layer to ArcMap by right-clicking on the group layer in ArcScene > Copy > right-click on ArcMap's data frame > Paste Layer(s). Next save the map document. Once you have the saved MXD you can run python on the group layer to sort the layer alphabetically. After the group layer is sorted in ArcMap, you can copy/paste the group layer back into the SXD. Here is an example how to sort the Group Layer:import arcpy
from arcpy import env
from arcpy import mapping
env.overwriteOutput = True
env.workspace = r"C:\temp\python"
folder = env.workspace
mxd = mapping.MapDocument(r"C:\temp\python\Scene.mxd")
list = []
for df in mapping.ListDataFrames(mxd, "*"):
for lyr in mapping.ListLayers(mxd, "*", df):
# Find layers within Group Layer
if "\\" in lyr.longName:
lyrName = str(lyr.name) + ".lyr"
list.append(lyrName)
# Save layers to .lyr files
arcpy.SaveToLayerFile_management(lyr, lyrName)
# Remove layers from Group Layer
mapping.RemoveLayer(df, lyr)
print "Successfully created layer files and removed layers"
# Order layer files in alphabetical order
list.sort(key=lambda x: x.lower())
# Add layer files to Group Layer in alphabetical order
for df in mapping.ListDataFrames(mxd, "*"):
for n in list:
for lyr in mapping.ListLayers(mxd, "3D", df):
targetGroupLayer = lyr
addLayer = mapping.Layer(folder + "\\" + n)
mapping.AddLayerToGroup(df, targetGroupLayer, addLayer, "BOTTOM")
print "Successfully reorderd Group Layer"
# Delete lyr files
lstFiles = arcpy.ListFiles("*.lyr")
for file in lstFiles:
arcpy.Delete_management(file)
print "Sucessfully deleted layer files"
mxd.save()
del mxd