Arcpy.mapping.layer() help files in 10.0 and 10.1

828
4
Jump to solution
01-10-2013 11:26 PM
JT2
by
New Contributor II
Is it just me, or is the help entry for arcpy.mapping.Layer() quite misleading?

It gives the distinct impression that you can only use this function on .lyr files, but actually you can pass a shapefile as a path and it works just fine.

So why does it imply that you can only reference a layer file (.lyr) as opposed to a map layer which could be one of any number of formats? Does anyone else agree that this entry could be clearer?
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
JeffBarrette
Esri Regular Contributor
This is an unintended feature.  The Layer function was originally designed to work only with layer files.  We have been made aware of its other uses.  Because users are starting to use it we avoided preventing it from working but choose not to update the help because of unknown, untested consequences.

Also - The Layer function is the same name as the Layer Class, just like the MapDocument function has the same name as the MapDocument Class.  They were designed to work the same way.

This issue is being evaluated.

Thanks,
Jeff

View solution in original post

0 Kudos
4 Replies
JT2
by
New Contributor II
And come to think of it, it's ridiculous that ESRI used the name Layer for the function when they also have a massive class called Layer. Surely someone could have thought of a different name for the function to avoid this ambiguity???
0 Kudos
curtvprice
MVP Esteemed Contributor
It's handy, and consistent with the UI (IMHO) that you can pass a feature class to this function. Layer inputs to tools can take a layer file, layer in the map, or a dataset. I agree it should be documented!

If you find anything in the help you don't like, you're welcome (and invited) to provide feedback using the button at the upper right of the page.

I know these comments gets read and used because when I provide my email address I get a personal email back from the doc team.

I agree that GetLayer may be a better name for the function. If you add it to ideas, I'll vote for it!
0 Kudos
JeffBarrette
Esri Regular Contributor
This is an unintended feature.  The Layer function was originally designed to work only with layer files.  We have been made aware of its other uses.  Because users are starting to use it we avoided preventing it from working but choose not to update the help because of unknown, untested consequences.

Also - The Layer function is the same name as the Layer Class, just like the MapDocument function has the same name as the MapDocument Class.  They were designed to work the same way.

This issue is being evaluated.

Thanks,
Jeff
0 Kudos
JT2
by
New Contributor II
Thanks for your helpful replies.

It's an aside, but I think that having a function called the same thing as a class is just plain confusing. Search the help files for Layer and you'll see two entries, if you're a beginner it's difficult to make sense of that. It's just not user friendly because you have two entires with the same name.

Anyway, thanks for the info
0 Kudos