Is it possible to open an existing toolbox (*.tbx) and read the tools into a collection?
Something along the lines of:
var toolboxPath = "C:\Data\ToolboxExample.tbx";
var toolbox = Toolbox.Open(toolboxPath);
ToolboxItemsCollection toolboxItems = toolBox.GetToolsList();
I'm wanting to write a WPF usercontrol that displays a list of all the geoprocessing tools in the toolbox, rather than needing to access them through the Catalog. I won't know at compile time which tools are in the toolbox so adding them as buttons in the DAML is not an option.
Solved! Go to Solution.
Hi,
Code for toolbox content below:
var gpItems = CoreModule.CurrentProject.Items.OfType<GeoprocessingProjectItem>();
// go through all the available toolboxes
foreach (var gpItem in gpItems)
{
var itemsInsideToolBox = gpItem.GetItems();
// then for each toolbox list the tools inside
foreach (var toolItem in itemsInsideToolBox)
{
string newTool = String.Join(";", new string[] { toolItem.Path, toolItem.Name });
// do something with the newTool
// for example, add to a list to track or use them later
}
}
If your toolbox is not added to project try to create it using ItemFactory:
var item = ItemFactory.Instance.Create(toolboxPath);
And add it to project.
More info here:
GeoprocessingProjectItem Class—ArcGIS Pro
Create Method (ItemFactory)—ArcGIS Pro
Hi,
Code for toolbox content below:
var gpItems = CoreModule.CurrentProject.Items.OfType<GeoprocessingProjectItem>();
// go through all the available toolboxes
foreach (var gpItem in gpItems)
{
var itemsInsideToolBox = gpItem.GetItems();
// then for each toolbox list the tools inside
foreach (var toolItem in itemsInsideToolBox)
{
string newTool = String.Join(";", new string[] { toolItem.Path, toolItem.Name });
// do something with the newTool
// for example, add to a list to track or use them later
}
}
If your toolbox is not added to project try to create it using ItemFactory:
var item = ItemFactory.Instance.Create(toolboxPath);
And add it to project.
More info here:
GeoprocessingProjectItem Class—ArcGIS Pro
Create Method (ItemFactory)—ArcGIS Pro
Thanks GintautasKmieliauskas! That's exactly what I was looking for.