As I suspected, the commands you execute with ICommandItem::Execute show a window for user input. I do not think you can programmatically input data into that window and programmatically "enter". You see, the command in question has already fulfilled its job which is to display the window. Thatwindow which displays is an instance of a different class. It is not an instance of the command's class. So the window/form you see is a separate objectwith its own properties and methods. If anything could be done that could possibly automate the process a little more, it would be up to the developer of the command and the window. For example, the developer can put default values in the form, but that would still not help. Had this been a geoprocessing tool (in a toolbox), youcould programmatically input the parameters of the tool and execute the tool in either VBA with ArcObjects or in a Python script/ModelBuilder, justlike you say. But a command that sits on a toolbar is not a geoprocessing tool (GP Function), and you cannot convert a command into a GP Function.You would have to develop it in C#, VB.NET, C++ or Java using ArcObjects and make it do the same as the command and for that, you need thesource code of those commands, in the first place. Perhaps there are already equivalent HecGeoRas geoprocessing tools out there. I remember havingworked with some of the USACE commands a good while back for drainage/flood studies.Anyway, programmatically executing a command with ICommandItem::Execute the way you are doing is intended more for those commands thatjust do something without showing a form for input, like executing the Full Extent command, which avoids having to use finer-grained ArcObjectscode needed for doing what an existing command already does.
Hi Trevor,I am trying to picture why a command (an instance of a class that implements ICommand) would have arguments that would need to be passed on to it after its OnClick method has executed, which is what happens when ICommandItem.Execute() is used with that command. By the time ArcMap opens and displays a command, the code in its OnCreate() and its constructor have already executed, and the class that defines the custom command has already been instantiated.Do the commands you are executing programmatically with ICommandItem.Execute() open a form/window for user input, and does such input correspond to the arguments you want to pass? I am trying to picture the argument(s) that such commands would have.
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.