arcpy Layer.longName doesn't work

2776
2
11-26-2010 07:33 AM
deleted-user-pYdfRjvSAbTJ
New Contributor III
Hello,
Is there a bug in longName read only property of Layer class?
I have a document with group layers, but when I enumerate layers and test the longName property I always obtain the same as name property.
according to the documentation it seems wrong: long name should contain the whole name (group layers name plus layer name).
any suggestion?

Thanks
0 Kudos
2 Replies
JeffMoulds
Esri Contributor
If I have a mxd with "New Group Layer" containing US Cities and US Counties layers, I can use this:

>>> import arcpy.mapping as ma 
>>> mxd = ma.MapDocument("current")
>>> lyr = ma.ListLayers(mxd,r"U.S. Cities")[0]
>>> print lyr.longName
New Group Layer\U.S. Cities


Or if I enumerate through all the layers:

>>> for lyr in ma.ListLayers(mxd):
...     print lyr.longName
... 
New Group Layer
New Group Layer\U.S. Cities
New Group Layer\U.S. Counties (Generalized)


Does this work for you?
0 Kudos
DavidMartin
Occasional Contributor II
I have ArcGIS 10 SP1 installed, and Layer.longName doesn't work for me. It returns the same as the .name property, regardless of whether the layer is in a group, or nested within several groups.

mxd = arcpy.mapping.MapDocument(pathtomxd)
df = arcpy.mapping.ListDataFrames(mxd)[0]
maplayers = arcpy.mapping.ListLayers(mxd, "", df)
for maplyr in maplayers:
   lyrname = maplyr.name
   longlyrname = maplyr.longName
   print "Layer Name is " + lyrname
   print "Layer Long Name is " + longlyrname
0 Kudos