I have developed a custom model using ModelBuilder in ArcGIS, and I would like to use a .NET Base Command to open the geoprocessor parameter window for this tool so the user can enter their parameters, same behavior as if I were double-clicking it in ArcToolbox, as opposed to just executing it programmatically without user interaction. Is this possible?
- possible duplicate of Is it possible to open ModelBuilder SCREEN from .NET base command class?Petr Krebs– Petr Krebs2011-05-03 06:49:44 +00:00Commented May 3, 2011 at 6:49
- @Petr This isn't a duplicate. The answer to the question you posted at the link opens up the model in the ModelBuilder editor window. I want to open the tool's geoprocessing tool dialog, the canned one that lets you enter parameters, view help on the right, and set environment at the bottom: Tool Dialog BasicsGady– Gady2011-05-11 16:25:04 +00:00Commented May 11, 2011 at 16:25
- you're right, sorry, I totally overlooked that.Petr Krebs– Petr Krebs2011-05-11 19:38:10 +00:00Commented May 11, 2011 at 19:38
Add a comment |
2 Answers
Very similarly to this answer, you can open a tool's dialog with the code below. The code sample opens up the dialog for the "Symmetrical Difference" tool, but you can use your model's name instead of "SymDiff".
// _app is an IApplication reference (e.g. ArcMap or ArcCatalog app) var arcToolBoxExtension = _app.FindExtensionByName("ESRI ArcToolbox") as IArcToolboxExtension; if (arcToolBoxExtension != null) { var arcToolBox = arcToolBoxExtension.ArcToolbox; var gpTool = arcToolBox.GetToolbyNameString("SymDiff"); if (gpTool != null) arcToolBox.InvokeTool(_app.hWnd, gpTool, null, false); } Petr has shown the answer, which is the GetToolbyName property on IArcToolbox. You can also refer to the SDK manual which will help you navigate the SDK: