Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

A total noob here:

Users here add a picture to a map using the 'add data' Their first task is to right-click the jpg in the Table of Contents, select 'properties', select 'symbology' and then 'Classify' and then choose a new colors for the different ranges (to make the background transparent).

I can create a model to do this and, alternatively, can write a arcpy script to do this but in both cases, I have to hard-code the name of the input layer.

QUESTION: How do I use the selected layer in the TOC (i.e. clicked via the mouse and is now highlighted) as the input (and output) to my script?

Ideally, the user would add the picture, click on it to highlight it (in the TOC) and then hit a key combination to execute the script. Any help is appreciated!

Best, Eric

share|improve this question
    
Eric - Did you ever find a way to do this with ArcPy methods? It doesn't seem like the MapDocument class has a SelectedItem property. Thanks, emeline –  Emeline G. Renz Jan 7 at 14:56
add comment

1 Answer

You can find the selected layer in the ArcMap Table Of Contents using iMXDocument::SelectedItem

Here's a simple VBA snippet:

Dim pMxDoc As IMxDocument
Dim pLayer As ILayer

Set pMxDoc = ThisDocument
Set pLayer = pMxDoc.SelectedItem

Steve

share|improve this answer
    
You mentioned ArcPy - unfortunately I'm not sure how to do this in ArcPy, hence my ArcObjects-based answer. I hope it at least gives some pointers –  Stephen Lead Sep 8 '11 at 6:01
    
Thanks for your response, Stephen. Appreciate the help. If anyone else has an arcpy solution, I'd love to hear it. –  Eric Sep 8 '11 at 6:26
1  
It's possible to access ArcObjects from within python, see: gis.stackexchange.com/questions/80/… –  DPierce Jan 7 at 15:00
add comment

Your Answer

 
discard

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.