IExternalCommand & IExternalApplication Classes are in different class libraries

IExternalCommand & IExternalApplication Classes are in different class libraries

JacobJose
Explorer Explorer
443 Views
4 Replies
Message 1 of 5

IExternalCommand & IExternalApplication Classes are in different class libraries

JacobJose
Explorer
Explorer

Hi,

 

I am rather new to Revit API programming. I have been trying to create an add-in whereby a pushbutton on the ribbon is created and that executes something upon being clicked on. I have been successful in making this work up to the point where the pushbutton and ribbon panel gets created on the ribbon but stops working once clicked with the error "External Tools - Wrong Full Class Name".

 

Here is how the skeleton of my code looks like:

  • Two classes, in the same solution, but different class libraries 
  • An add-in file in the Revit add-ins folder pointing to appropriate IExternalApplication class information
  • The first class (Main) implements the IExternalApplication interface and creates the PushButtonData for the PushButton
  • The second class implements the IExternalCommand interface

Please note, the add-in does work fine if I move both classes in the same class library, but fail when they're in different class libraries like the setup I have above. I don't think there is a problem with the add-in manifest file because the pushbutton gets initialized and created every time I open Revit. Revit just can't seem to find the class in the assembly when the pushbutton is clicked. Am I missing something in terms of how I built the DLL's or their referencing? 

 

Thank you.

 

 

0 Likes
Accepted solutions (1)
444 Views
4 Replies
Replies (4)
Message 2 of 5

ricaun
Advisor
Advisor

Probably your implementation of the pushbutton is not right.

 

"External Tools - Wrong Full Class Name" probably means that you are pointing to the wrong assembly or wrong class.

 

Luiz Henrique Cassettari

ricaun.com - Revit API Developer

AppLoader EasyConduit WireInConduit ConduitMaterial CircuitName ElectricalUtils

0 Likes
Message 3 of 5

JacobJose
Explorer
Explorer

Thanks for the response, ricaun.

 

The clip below shows the main class implementing the IExternalApplication. In connection with your comment, could you perhaps check if my entry "cbbcore.Command2" should be something else for the pushbutton?  

JacobJose_1-1698950619926.png

 

 

 

0 Likes
Message 4 of 5

ricaun
Advisor
Advisor
Accepted solution

There is the issue.

Assembly.GetExecutingAssembly().Location is pointing to the cbb.dll, not the cbbcore.dll that has the class cbbcode.Command2.

 

Usually is a good approach to use typeof to manage the location and full name of the IExtenalCommand.

 

var buttonData = new PushButtonData("btnDataName", "My Button",
    typeof(cbbcore.Command2).Assembly.Location,
    typeof(cbbcore.Command2).FullName);

 

If your cbb project has the cbbcode as a project reference, the compiler gonna build with no problem.

 

Luiz Henrique Cassettari

ricaun.com - Revit API Developer

AppLoader EasyConduit WireInConduit ConduitMaterial CircuitName ElectricalUtils

0 Likes
Message 5 of 5

JacobJose
Explorer
Explorer
Hey many thanks, Luiz! This worked like a charm and saved many more countless hours trying to figure it out.