Is it possible to add all my toolbox tools to a toolbar ribbon in arcpro?
but that geoprocessing tool isn't using python or arctoolbox? I tried the callsriptfromnet one but could never get it to run my tool. I'm sorry I'm pretty frustrated and would love any help and below is the python tool I would like to run.
Hi
To run a specific GP Tool using the Pro API, you can call the ExecuteToolAsync method. There are some samples available that will walk you through this:
Sample that uses a GP Tool.
Some more code snippets that runs GP Tools
If you need to open a specific GP Tool dialog using code, you can do something like this:
<SPAN class="keyword token">string</SPAN> input_data <SPAN class="operator token">=</SPAN> <SPAN class="string token">@"C:\data\data.gdb\Population"</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">string</SPAN> out_pdf <SPAN class="operator token">=</SPAN> <SPAN class="string token">@"C:\temp\Reports.pdf"</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">string</SPAN> field_name <SPAN class="operator token">=</SPAN> <SPAN class="string token">"INCOME"</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="comment token">// use defaults for other parameters - no need to pass any value</SPAN> <SPAN class="keyword token">var</SPAN> arguments <SPAN class="operator token">=</SPAN> Geoprocessing<SPAN class="punctuation token">.</SPAN><SPAN class="token function">MakeValueArray</SPAN><SPAN class="punctuation token">(</SPAN>input_data<SPAN class="punctuation token">,</SPAN> out_pdf<SPAN class="punctuation token">,</SPAN> field_name<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">string</SPAN> toolpath <SPAN class="operator token">=</SPAN> <SPAN class="string token">@"C:\data\WorkflowTools.tbx\MakeHistogram"</SPAN><SPAN class="punctuation token">;</SPAN> Geoprocessing<SPAN class="punctuation token">.</SPAN><SPAN class="token function">OpenToolDialog</SPAN><SPAN class="punctuation token">(</SPAN>toolpath<SPAN class="punctuation token">,</SPAN> args<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
You can use the Pro SDK Item templates and create a button item in a Pro add-in. The OnClick event stubbed out for you via the template is where you would add code to access/run a specific GP tool.
This button can then be displayed directly on the Pro ribbon or you can add them to a "toolbar" on the Pro ribbon.
Thanks
Uma
also I am a little lost on how I connect it to a tool in a toolbox.
Yes. If you check out line 150 in the config.daml in this sample, it shows how to add toolbars to the ribbon.
HI Uma,
Are you talking about the config.daml in visual studio when opening that sample?
Hi Laura
Yes, Tools can be added to a Toolbar on the Pro ribbon.
You can define which tools/buttons you want on the toolbar using this piece of code in your config.daml:
<SPAN class="token tag"><SPAN class="token tag"><SPAN class="punctuation token"><</SPAN>toolbars</SPAN><SPAN class="punctuation token">></SPAN></SPAN> <SPAN class="token tag"><SPAN class="token tag"><SPAN class="punctuation token"><</SPAN>toolbar</SPAN> <SPAN class="attr-name token">id</SPAN><SPAN class="attr-value token"><SPAN class="punctuation token">=</SPAN><SPAN class="punctuation token">"</SPAN>TestToolbar<SPAN class="punctuation token">"</SPAN></SPAN><SPAN class="punctuation token">></SPAN></SPAN> <SPAN class="token tag"><SPAN class="token tag"><SPAN class="punctuation token"><</SPAN>group</SPAN><SPAN class="punctuation token">></SPAN></SPAN> <SPAN class="token tag"><SPAN class="token tag"><SPAN class="punctuation token"><</SPAN>button</SPAN> <SPAN class="attr-name token">refID</SPAN><SPAN class="attr-value token"><SPAN class="punctuation token">=</SPAN><SPAN class="punctuation token">"</SPAN>ArcProToolbar_ButtonOnToolbar<SPAN class="punctuation token">"</SPAN></SPAN> <SPAN class="punctuation token">/></SPAN></SPAN> <SPAN class="token tag"><SPAN class="token tag"><SPAN class="punctuation token"><</SPAN>tool</SPAN> <SPAN class="attr-name token">refID</SPAN><SPAN class="attr-value token"><SPAN class="punctuation token">=</SPAN><SPAN class="punctuation token">"</SPAN>ArcProToolbar_MyMapTool<SPAN class="punctuation token">"</SPAN></SPAN><SPAN class="punctuation token">></SPAN></SPAN><SPAN class="token tag"><SPAN class="token tag"><SPAN class="punctuation token"></</SPAN>tool</SPAN><SPAN class="punctuation token">></SPAN></SPAN> <SPAN class="token tag"><SPAN class="token tag"><SPAN class="punctuation token"><</SPAN>tool</SPAN> <SPAN class="attr-name token">refID</SPAN><SPAN class="attr-value token"><SPAN class="punctuation token">=</SPAN><SPAN class="punctuation token">"</SPAN>ArcProToolbar_MyConstructionTool1<SPAN class="punctuation token">"</SPAN></SPAN><SPAN class="punctuation token">></SPAN></SPAN><SPAN class="token tag"><SPAN class="token tag"><SPAN class="punctuation token"></</SPAN>tool</SPAN><SPAN class="punctuation token">></SPAN></SPAN> <SPAN class="token tag"><SPAN class="token tag"><SPAN class="punctuation token"></</SPAN>group</SPAN><SPAN class="punctuation token">></SPAN></SPAN> <SPAN class="token tag"><SPAN class="token tag"><SPAN class="punctuation token"></</SPAN>toolbar</SPAN><SPAN class="punctuation token">></SPAN></SPAN> <SPAN class="token tag"><SPAN class="token tag"><SPAN class="punctuation token"></</SPAN>toolbars</SPAN><SPAN class="punctuation token">></SPAN></SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
And then you add the toolbar using its refID to the group and the tab like this:
<SPAN class="token tag"><SPAN class="token tag"><SPAN class="punctuation token"><</SPAN>tabs</SPAN><SPAN class="punctuation token">></SPAN></SPAN> <SPAN class="token tag"><SPAN class="token tag"><SPAN class="punctuation token"><</SPAN>tab</SPAN> <SPAN class="attr-name token">id</SPAN><SPAN class="attr-value token"><SPAN class="punctuation token">=</SPAN><SPAN class="punctuation token">"</SPAN>ArcProToolbar_Tab1<SPAN class="punctuation token">"</SPAN></SPAN> <SPAN class="attr-name token">caption</SPAN><SPAN class="attr-value token"><SPAN class="punctuation token">=</SPAN><SPAN class="punctuation token">"</SPAN>New Tab<SPAN class="punctuation token">"</SPAN></SPAN><SPAN class="punctuation token">></SPAN></SPAN> <SPAN class="token tag"><SPAN class="token tag"><SPAN class="punctuation token"><</SPAN>group</SPAN> <SPAN class="attr-name token">refID</SPAN><SPAN class="attr-value token"><SPAN class="punctuation token">=</SPAN><SPAN class="punctuation token">"</SPAN>ArcProToolbar_Group1<SPAN class="punctuation token">"</SPAN></SPAN> <SPAN class="punctuation token">/></SPAN></SPAN> <SPAN class="token tag"><SPAN class="token tag"><SPAN class="punctuation token"></</SPAN>tab</SPAN><SPAN class="punctuation token">></SPAN></SPAN> <SPAN class="token tag"><SPAN class="token tag"><SPAN class="punctuation token"></</SPAN>tabs</SPAN><SPAN class="punctuation token">></SPAN></SPAN> <SPAN class="token tag"><SPAN class="token tag"><SPAN class="punctuation token"><</SPAN>groups</SPAN><SPAN class="punctuation token">></SPAN></SPAN> <SPAN class="comment token"><!-- comment this out if you have no controls on the Addin tab to avoid an empty group--></SPAN> <SPAN class="token tag"><SPAN class="token tag"><SPAN class="punctuation token"><</SPAN>group</SPAN> <SPAN class="attr-name token">id</SPAN><SPAN class="attr-value token"><SPAN class="punctuation token">=</SPAN><SPAN class="punctuation token">"</SPAN>ArcProToolbar_Group1<SPAN class="punctuation token">"</SPAN></SPAN> <SPAN class="attr-name token">caption</SPAN><SPAN class="attr-value token"><SPAN class="punctuation token">=</SPAN><SPAN class="punctuation token">"</SPAN>Group 1<SPAN class="punctuation token">"</SPAN></SPAN> <SPAN class="attr-name token">appearsOnAddInTab</SPAN><SPAN class="attr-value token"><SPAN class="punctuation token">=</SPAN><SPAN class="punctuation token">"</SPAN>false<SPAN class="punctuation token">"</SPAN></SPAN><SPAN class="punctuation token">></SPAN></SPAN> <SPAN class="comment token"><!-- host controls within groups --></SPAN> <SPAN class="token tag"><SPAN class="token tag"><SPAN class="punctuation token"><</SPAN>toolbar</SPAN> <SPAN class="attr-name token">refID</SPAN><SPAN class="attr-value token"><SPAN class="punctuation token">=</SPAN><SPAN class="punctuation token">"</SPAN>TestToolbar<SPAN class="punctuation token">"</SPAN></SPAN> <SPAN class="punctuation token">/></SPAN></SPAN> <SPAN class="token tag"><SPAN class="token tag"><SPAN class="punctuation token"></</SPAN>group</SPAN><SPAN class="punctuation token">></SPAN></SPAN> <SPAN class="token tag"><SPAN class="token tag"><SPAN class="punctuation token"></</SPAN>groups</SPAN><SPAN class="punctuation token">></SPAN></SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
The RibbonControls sample has a toolbar in it.
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.