5

I want to confirm whether arcpy can customize the right click menu of the selected feature, which means I want to remove the default items and add in my own item. The following pictures show what I want to do:

(1) picture 1 - the default when right click a selected feature

enter image description here

(2) - picture 2 - what I want when right click a selected feature

enter image description here

8

Unfortunately, this type of modifications is not accessible via Python (arcpy or python add-ins). I believe you can change this with ArcObjects though. I recommend looking at ArcGIS Add-in, here is a good 10.1 sample to start with.

The closest you can get is to create a Python add-in button on a toolbar which user can click on when having selected a feature. This triggers opening a custom window (wxPython for instance) or web browser window or a .pdf file or alike.

EDIT: I have just found out that you actually can modify the look of the right-click menu (apart from dozens of other menus) in ArcGIS. Customize menu > Customize Mode > Toolbars tab > Tick Context Menus > in the Context Menus toolbar click drop-down list > go to Data View Context Menu. Then you can drag and drop to this list what items you want to have (and delete existing ones if you don't need them). Esri Help page on that is here.

So, in order to get your workflow working on a user machine, you need two things. First, you have to supply the configuration file for the customization (it is called the template file, Normal.mxt, stored C:\Users\user\AppData\Roaming\ESRI\Desktop10.2\ArcMap\Templates. Here the customization outlook is preserved). I believe the context menus customization should follow just like any other customization of toolbars. Second, you will need to build a custom tool (I'd go for Python Add-in, but I guess script tool which has an output format of .pdf file would work too). This tool will search for a selected feature in the current map, identify the file document associated with it based on some ID and then fire up the .pdf reader or other application for document interaction.

enter image description here

  • Hi Alex, thanks for your quick reply. I think I need to change to ArcObects, the user is not supposed to go through the add-in button in my case. – ppLily May 30 '14 at 7:00
  • @user30643, I see. I have updated the answer to include a 10.1 Help link with a sample on .NET add-in. – Alex Tereshenkov May 30 '14 at 7:32
  • @user30643, have edited my post, have found a way to do what you want! – Alex Tereshenkov May 30 '14 at 7:42
  • Hi Alex, your answer is very clear and useful. Thank you very much for your effort on it! – ppLily May 30 '14 at 8:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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