Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I use ArcObject in python to develope a tool. I import comtypes in python to access the arcmap layers in python and use ifeaturelayer interface. I have to set featurelayer to phookhelper.focusmap.get_layer(i) to access the layers in ArcMap. The problem is that I can't find get_layer method in python. Is there any way to access the ArcMap layers in python using ArcObjects?

for (int i = 0; i < phookhelper.FocusMap.LayerCount; i++)
                if (phookhelper.FocusMap.get_Layer(i).Name == comboBox1.Text)
                    pfeaturelayer = (IFeatureLayer)phookhelper.FocusMap.get_Layer(i);

                    pfc = pfeaturelayer.FeatureClass;
share|improve this question
up vote 2 down vote accepted

Try Layer[i] instead of get_Layer(i).

Instead of using IHookHelper you can get a reference to the ArcMap application, cast it to IMxApplication and then get its FocusMap.

More pointers here:

Useful helper module here:

share|improve this answer
could you please write the cast code ? – wetland Oct 6 '12 at 7:54
Like this: CType(pApp, esriArcMapUI.IMxApplication) where CType is a helper function defined in either of the above links, pApp is an IApplication reference, and esriArcMapUI is a reference to the comtypes.gen wrapper around the esriArcMapUI.olb library. – blah238 Oct 6 '12 at 20:07

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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