Error loading .dll file into revit

Error loading .dll file into revit

Anonymous
Not applicable
1,698 Views
3 Replies
Message 1 of 4

Error loading .dll file into revit

Anonymous
Not applicable

Hi people. Having a bit of trouble loading my dll file into Revit. 

 

I am getting the following error message:

 

Capture.PNG

 

I know for certain it has something to do with how I am structuring my IExternalCommand and My IExternalApplication. I have a main class that talks to the extensions classes (to execute the various commands) which I have used IExternalCommand as follows. 

 

using System.Linq;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;

namespace DoorTag
{
    [TransactionAttribute(TransactionMode.Manual)]
    [RegenerationAttribute(RegenerationOption.Manual)]
    public class MoveDoors : IExternalCommand
    {
        // implement the command 
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            //Get application and document objects
            UIApplication uiApp = commandData.Application;
            Document doc = uiApp.ActiveUIDocument.Document;

            // get the active document in revit 
            var activeDoc = commandData.Application.ActiveUIDocument.Document;
            var activeView = commandData.Application.ActiveUIDocument.ActiveGraphicalView;

            // create a new filtered collection of door tags and their ids
            var tagCollector = new FilteredElementCollector(activeDoc, activeView.Id);

            // Find the doors whos tags needs to be moved  ---'tagsToMove' 
            var tagsToMove = tagCollector.
            OfCategory(BuiltInCategory.OST_DoorTags).
            OfClass(typeof(IndependentTag)).
            OfType<IndependentTag>().

            // calling an external method that will test if the door is a valid door type. 
            Where(tag => tag.IsAttachedToValidDoor(true));

            foreach (var tag in tagsToMove)
            {
                tag.MoveToCorrectPosition();
            }
            return Result.Succeeded;
        }

    }
}
        

and I have used a App class to made a small icon for my new addin. 

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using System.Windows.Media.Imaging;

namespace DoorTag
{

    class App : IExternalApplication
    {
        // define a method that will create our tab and button
        static void AddRibbonPanel(UIControlledApplication application)
        {
            // Create a custom ribbon tab
            String tabName = "PTW";
            application.CreateRibbonTab(tabName);

            // Add a new ribbon panel
            RibbonPanel ribbonPanel = application.CreateRibbonPanel(tabName, "Tools");

            // Get dll assembly path
            string thisAssemblyPath = Assembly.GetExecutingAssembly().Location;

            // create push button for doortag command
            PushButtonData b1Data = new PushButtonData(
                "cmdDoorTag",
                "Fix Door" + System.Environment.NewLine + "  Tags  ",
                thisAssemblyPath,
                "DoorTag.MoveDoorTags");

            PushButton pb1 = ribbonPanel.AddItem(b1Data) as PushButton;
            pb1.ToolTip = "Move all the door tags in your open project to their correct position within the door leaf";
            BitmapImage pb1Image = new BitmapImage(new Uri("pack://application:,,,/DoorTagProject/component/Resources/DoorTagIcon.png"));
            pb1.LargeImage = pb1Image;
        }

        public Result OnShutdown(UIControlledApplication application)
        {
            // do nothing
            return Result.Succeeded;
        }

        public Result OnStartup(UIControlledApplication application)
        {
            // call our method that will load up our toolbar
            AddRibbonPanel(application);
            return Result.Succeeded;
        }
    }
}

My manifest is as follows 

 

<?xml version="1.0" encoding="utf-8"?>
<RevitAddIns>
  <AddIn Type="Command">    
    <Assembly>
      C:\test\DOOR_TAGS\DoorTagProject\DoorTagProject\bin\Release\DoorTagProject.dll
    </Assembly>
    <ClientId>9a3e9d19-9303-4f2d-8a64-4db4d7eef795</ClientId>
    <FullClassName>DoorTag.App</FullClassName>
    <Text>DoorTag</Text>
    <VendorId>PTW</VendorId>
    <VisibilityMode>AlwaysVisible</VisibilityMode>
  </AddIn>
</RevitAddIns>

Does anyone know what I am doing wrong? 

0 Likes
1,699 Views
3 Replies
Replies (3)
Message 2 of 4

jeremytammik
Autodesk
Autodesk

Obviously, it is important for you to understand your error to avoid repeating it in future.

 

However, simply solving your problem without worrying about the cause is probably much faster.

 

Two suggestions: 

 

One. Restart from scratch and follow the hello world examples provided in the developer guide:

 

http://help.autodesk.com/view/RVT/2018/ENU/?guid=GUID-93BC4416-FA94-44B3-AA66-931839DA44B4

 

Since you can reuse all your existing code and just need to get the framework up and running, it should be quick to do.

 

Two. Install and run the Visual Studio Revit add-in wizard, then copy your existing code into the skeleton it creates:

 

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

 

That should be even quicker.

 

Cheers,

 

Jeremy



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

Message 3 of 4

Anonymous
Not applicable

Hi @jeremytammik

 Thank you for the advice. Love your blog by the way!

 

Although I eliminated the first error, I am still getting this error message after trying your second suggestion (which seemed the safest):

 

 

Capture2.PNG

 

 

I have a feeling that the C# template for Revit is made for Revit 2018 which means by 2016 Revit doesn't have a good time trying to read the file. It is either that or I haven't registered by addin, properly. another

Another idea is that the classes are not reading the various extension classes well. I have multiple classes within my project including a 'App' class that gives me my new icon and command button, a 'Command' class that gives me my new entry point to the Iexternal command, and then I have multiple other classes like 'FamilyInstanceExtensions' and 'IndepependentTagExtensions" that the 'Command class references to perform its function. Let me know if I should 

 

What do you reckon I should do to fix this? If you need more info, I can post my source code but I am not sure how much difference it will make since I used the template that your most up-to-date github template produced and everything is compiling fine. From what it appears like, it is just a loading error. PLEASE HELP ME! 

 

 

0 Likes
Message 4 of 4

Anonymous
Not applicable

Here is my source code and Manifest. 

0 Likes