How to get a Layer as ILayer (ArcObjects)

المشرف العام

Administrator
طاقم الإدارة
I had asked this question previously which I think will work. But as I am new to this, I can't figure out how to get a Layer as an ILayer object to pass to the method that's in my previous questions answer.

I have been playing with the Mark Cederholm's 'Snippets.py' that uses comtypes to drive ArcObjects. That works well, but I don't know enough to venture far from the examples given. It first gets an IMxApplication object, and I can't figure out how to get a Layer file as an ILayer from this object so that I can use the script I was shown in my previous question.

In the end I want to be able to change the Display Expression of some Table Views, and be able to grab them by their name in the TOC.

Note: If you know how to do this with C# or VBA, I can figure it out in Python

Update: Here is the answer in Python which relies on Mark Cederholm's Snippets.py and comtypes:

from Snippets import * GetDesktopModules() import comtypes.gen.esriCarto as esriCarto import comtypes.gen.esriArcMapUI as esriArcMapUI InitStandalone() pApp = GetApp() pMxDoc = CType(pApp.Document, esriArcMapUI.IMxDocument) pFeatureLayer = CType(pMxDoc.FocusMap.Layer(0), esriCarto.IFeatureLayer)

أكثر...
 
أعلى