2

I have an ArcGIS Python Add-in project with a tool palette that contains a dozen different tools. I would like to be able to change the 'active tool', i.e. the tool that is visible on the toolbar, when a button on the same toolbar is clicked.

The active tool changes when the user selects a tool from the dropdown palette, but I'm not sure if this behaviour can be replicated using Python.

asked Dec 2, 2014 at 3:47
1
  • In ArcObjects it's IApplication.CurrentTool help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/… but no analogue for arcpy exists. There is a slim possibility of invoking ArcObjects from python but without a GUID/CLSID for a python add-in you can't specify it even then. Commented Dec 2, 2014 at 4:08

1 Answer 1

1

To change the active tool in ArcObjects use the CurrentTool property of IApplication object:

public void CurrentTool(IApplication app)
{
 ICommandBars documentBars = app.Document.CommandBars;
 UID cmdID = new UIDClass();
 cmdID.Value = "{B7FA188F-EBE3-11D0-87FE-080009EC732A}";
 ICommandItem cmdItem = documentBars.Find(cmdID, false, false);
 app.CurrentTool = cmdItem;
}

Which uses the UID/CLSID of the command to identify it. To my knowledge Python tools don't have CLSIDs so you can't invoke them this way. Tools written in .net have CLSIDs embedded in them at creation so are subject to this method.

It is possible to use ArcObjects in python, there's a basic discourse here and a more complete post Accessing ArcObjects from Python?. If you can find a way to associate a CLSID/UID with the tool then it is possible.

answered Dec 4, 2014 at 23:11

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.