0
[Transaction(TransactionMode.Manual)]
    public class InteropCommand<T, V> : IExternalCommand
    {
        public Result Execute( ExternalCommandData commandData, ref string message,
                               ElementSet elements )
        {
             InterfaceDialog<T, V> interfaceDlgBox = new InterfaceDialog<T, V>( (IDocumentationModel<T>)Revit2014Model );

        }
}

The command.cs file looks like shown above. If I write class as class InteropCommand then I need to change the .Addin file accordingly otherwise the command will not work. Now I have question that how can I write a command class in such a way that it will load the Revit addin command. In current scenario I am not able to load the Revit command.

My .Addin file look like below. Do you have any idea how to tackle with this kind of problem ?

<RevitAddIns>
  <AddIn Type="Command">
    <Text>Test</Text>
    <Description>Test Command</Description>
    <Assembly>test.dll</Assembly>
    <FullClassName>InteropCommand</FullClassName>
    <ClientId>0072bf73-c900-449b-bce2-e50a899a72ae</ClientId>
    <VendorId>XYZ</VendorId>
    <VendorDescription>XYZ</VendorDescription>
  </AddIn>
</RevitAddIns>

2 Answers2

0

You need to implement a separate class for each command.

You can derive all your external command implementation classes from a single base class to share part of the implementation, or call a generic class from each individual external command implementation class' Execute method.

Jeremy Tammik
  • 7,333
  • 2
  • 12
  • 17
0

Adding to Jeremy's reply, you can have a class that implements IExternalApplication, then on the OnStartup method, create as many IExternalCommands as you want, on the fly, without changing the .addin file.

This still requires one class for each command, as already mentioned.

Community
  • 1
  • 1
Augusto Goncalves
  • 8,493
  • 2
  • 17
  • 44