
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi!
I was following @jeremytammik 's post here https://thebuildingcoder.typepad.com/blog/2013/02/adding-a-button-to-existing-ribbon-panel.html as I want to add a custom panel with custom buttons to one of our existing tabs, but I can't just add it as you would always do, because that existing tab is created through pyRevit (and it can't be created via pyRevit as it needs to access a few things pyRevit cannot access).
I initially thought it wouldn't have worked to add custom C# panels to an existing pyRevit tab, but I tried mostly out of curiosity and I found out it actually is possible! So I followed the steps from the post (link above) and I'm able to create the same button within my pyRevit tab.
The problem I have is that I don't want to open the browser but start an IExternalCommand. So I found this other link https://thebuildingcoder.typepad.com/blog/2009/12/custom-ribbon-tab.html but then it fails because the Execute(object a) implementation sets ExternalCommandData commandData = null; so then the IExternalCommand fails to retrieve the Application.
public class AdskCommandHandler : System.Windows.Input.ICommand
{
string AssemblyName
{
get;
set;
}
string ClassName
{
get;
set;
}
public AdskCommandHandler(
string assemblyName,
string className)
{
AssemblyName = assemblyName;
ClassName = className;
}
public event EventHandler CanExecuteChanged;
public bool CanExecute(object a)
{
return true;
}
public void Execute(object a)
{
Assembly assembly = Assembly.LoadFrom(AssemblyName);
IExternalCommand command = assembly.CreateInstance(ClassName) as IExternalCommand;
ExternalCommandData commandData = null; // Here is the issue
string message = string.Empty;
ElementSet elements = null;
Result r = command.Execute(commandData,
ref message, elements);
}
}
I've read from the comments Jeremy is saying that we're not supposed to use this workaround because it's not officially supported but then he sends a couple more articles (https://thebuildingcoder.typepad.com/blog/2009/12/create-a-real-revit-ribbon-tab.html and https://thebuildingcoder.typepad.com/blog/2010/01/custom-ribbon-tab-context-switch.html) mentioning Guy Robinson managed to fix this. Now I'd really like to see how he did it, but the links in those 2 posts are not working anymore.
Any chance anyone has those links functioning??
Also curious to see if there are better ways of doing what I'm trying to do?
Solved! Go to Solution.