Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iexternalc​ommandavai​lability

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
crthomas
426 Views, 4 Replies

iexternalc​ommandavai​lability

I need help understanding where to place the code for iexternalcommandavailability.

 

I have created a custom Ribbon Tab and have two External Commands that I wish to make available in a no document state.

 

Currently, each External Command is written and compiled seperately. I then have a separate External Application that builds the Ribbon Tab and Panels and loads the External Commands.

4 REPLIES 4
Message 2 of 5
Anonymous
in reply to: crthomas

First, you need to create a class that implements IExternalCommandAvailability that always returns true.  This is what I use:

 

public class AlwaysAvailable : IExternalCommandAvailability
    {
        public bool IsCommandAvailable(UIApplication a, CategorySet b)
        {
            return true;
        }
    }

 

Then set the Availability Class as follows:

 

var button = new PushButtonData(...)
                {
                    AvailabilityClassName = "YourNameSpace.AlwaysAvailable"
                };

or:

var button = new PushButtonData(...);
button.AvailabilityClassName = "YourNameSpace.AlwaysAvailable";

Then add the PushButton to your ribbon as normal.

 

Message 3 of 5
jeremytammik
in reply to: crthomas

Here are a couple of blog posts on The Building Coder that include sample code demonstrating the usage:

 

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 4 of 5
crthomas
in reply to: Anonymous

Thanks for the code snippet ... the "YourNameSpace" reference helped clarify what I was supposed to be referencing.

Message 5 of 5
crthomas
in reply to: jeremytammik

Thanks Jeremy ... I had read your Zero Document State post before, and even though you said

 

"By the way, you have to read the documentation of the IExternalCommandAvailability interface pretty carefully.  One of the statements it makes is "This interface should share the same assembly with add-in External Command".

 

I kept trying to put the Availability class in with my External Application instead of the External Command.

 

So, between your reply and the previous one I was able to make it work.

 

Thanks again.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community