IExternalCommand could not be found

IExternalCommand could not be found

Kevin.Bell
Advisor Advisor
1,840 Views
4 Replies
Message 1 of 5

IExternalCommand could not be found

Kevin.Bell
Advisor
Advisor

Hi,

 

I've decided to have another go at building a ribbon for Revit to run some of my C# commands.

 

The Revit SDK 2017 has a Ribbon example, which I've decided to try to use.

 

When I open the solution in Visual Studio I get loads of compile errors, the first one being:

 

The type or namespace name 'IExternalCommand' could not be found (are you missing a using directive or an assembly reference.

 

I'm using Revit 2017. I've added RevitAPI and RevitAPIUI into the solutions references, and the code has the following using directives at the beginning (these were part of the original Autodesk ribbon sample code - I've not changed anything):

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Autodesk.Revit;
using Autodesk.Revit.DB;
using System.Diagnostics;
using System.IO;
using System.Collections;
using Autodesk.Revit.UI;
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes;
using System.Windows.Media.Imaging;

 

I've also changed the .net framework to 4.5.2 - I understand that Revit 2017 uses this.

 

But still the build errors - Am I missing something?

 

Thanks.

0 Likes
1,841 Views
4 Replies
Replies (4)
Message 2 of 5

aignatovich
Advisor
Advisor

Hi!

 

Open csproj file in any text editor and ensure, that RevitAPI and RevitAPIUI reference hint path points towards right location:

    <Reference Include="RevitAPI">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>C:\Program Files\Autodesk\Revit Architecture 2017\RevitAPI.dll</HintPath>
      <Private>False</Private>
    </Reference>

 

 

I am almost sure, that you Revit is in "C:\Program Files\Autodesk\Revit 2017\" folder, not in Revit Architecture 2017

0 Likes
Message 3 of 5

jeremytammik
Autodesk
Autodesk

The best way to avoid all problems with loading is to understand what is going on.

 

It is very simple and explained in full detail in the developer guide section on getting started:

 

http://help.autodesk.com/view/RVT/2018/ENU/?guid=GUID-C574D4C8-B6D2-4E45-93A5-7E35B7E289BE

 

Another way, in case you wish to avoind any under the hood knowledge, is to use the Visual Studio Revit add-in wizard:

 

http://thebuildingcoder.typepad.com/blog/about-the-author.html#5.20

 

My wizard is minimal and simple and just solves your loading problem.

 

Please also note the alternative, more complex and full-fledged Revit2017AddInTemplateSet provided by Andrey Bushman.

 

That will probably generate your entire ribbon panel for you automatically, if you like.

 

Cheers,

 

Jeremy



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

0 Likes
Message 4 of 5

Kevin.Bell
Advisor
Advisor

@aignatovich - Looking at the csproj file, it seems that the Autodesk DLLs were set to a relative path from the SDK installation location - I copied the Ribbon sample folder (as I wanted to amend it) - but the new location couldn't find the DLLs

 

But I amended the reference path as you suggested and it still came up with the same error - I even tried deleting the reference and re-adding it - same error...

 

I did try opening the ribbon project from the SDK - and this opened fine - I'll try working with that.

 

@Anonymous - I normally use your Visual Studio addin wizard when starting a new project - but this time I wanted to open the existing project - and copying it to a new location caused the errors I think.

 

Is there a way to open an existing project using the addin wizard?

 

0 Likes
Message 5 of 5

jeremytammik
Autodesk
Autodesk

Oh, I see.

 

Nope, sorry... just intended as a quick and dirty way to get going really fast for a rapid test command...

 

Cheers,

 

Jeremy



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

0 Likes