"...does not inhert IExternalCommand"

"...does not inhert IExternalCommand"

Anonymous
Not applicable
654 Views
2 Replies
Message 1 of 3

"...does not inhert IExternalCommand"

Anonymous
Not applicable

 Hi guys,

I'm create a tool to visible hello/goodbye with WPF and Revit API.

I just found out so I am not sure about it.
When i debug, dialog warning like under pic.
Where is my code wrong ?
Thank in advanced

Screenshot_1.png

0 Likes
655 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB.Structure;

namespace MyFirstCommand
{
    [TransactionAttribute(TransactionMode.Manual)]
    public partial class UserControl1 : IExternalCommand
    {
        
        public UserControl1()
        {
            InitializeComponent();
        }

        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {

            return Result.Succeeded;
        
        }

        private void Button1_Click(object sender, RoutedEventArgs e)
        {
            if (Hellobtn.IsChecked == true)
            {
                MessageBox.Show("Hello!");
            }

            else if (Goodbyebtn.IsChecked == true)
            {
                MessageBox.Show("Goodbye!");
            }


        }



    }
}

UserControl1.cs above:

UserControl1.xaml under:

Window x:Class="MyFirstCommand.UserControl1"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:MyFirstCommand"
             mc:Ignorable="d" 
             Height="223.5" Width="615.5">
    <Grid Margin="2,10,0,0">
        <Button x:Name="button1" Content="Click here" HorizontalAlignment="Left" VerticalAlignment="Top" Width="134" Margin="273,48,0,0" Height="28" Click="Button1_Click"/>
        <RadioButton x:Name="Hellobtn" Content="Hello" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="185,112,0,0"/>
        <RadioButton x:Name="Goodbyebtn" Content="Goodbye" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="430,112,0,0"/>

    </Grid>
</Window>

 

 

 

 

0 Likes
Message 3 of 3

jeremytammik
Autodesk
Autodesk

Please work through the getting started material first of all to learn and understand the basics of Revit add-ins:

 

https://thebuildingcoder.typepad.com/blog/about-the-author.html#2

 

That will answer this question of yours and many others as well.

 

Your specific question is probably due to an error in your add-in manifest, so you ought to share that as well.

 

To fix your error, please look at the Add-in Registration instructions in the developer guide:

 

https://help.autodesk.com/view/RVT/2020/ENU/?guid=Revit_API_Revit_API_Developers_Guide_Introduction_...

  

You must specify your add-in DLL path and your full external command class name, which is:

 

  • MyFirstCommand.UserControl1

 

This name seems rather confusing to me, so, for your own sake and peace of mind, you might want to think of more precise and descriptive names for both your namespace and your external command implementation class.

 

Cheers,

 

Jeremy

 



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