My First Plug-in (failed to initialize)

My First Plug-in (failed to initialize)

JFN_KSH
Advocate Advocate
2,515 Views
10 Replies
Message 1 of 11

My First Plug-in (failed to initialize)

JFN_KSH
Advocate
Advocate

I'm trying to follow the My First Plug-in series tutorial... I'm getting this error (see image)Capture.JPG & I don't have a clue why? I'm using frameworks 4.5.2 here's my VB code:

Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports Autodesk.Revit.DB
Imports Autodesk.Revit.DB.Architecture
Imports Autodesk.Revit.UI
Imports Autodesk.Revit.UI.Selection
Imports Autodesk.Revit.ApplicationServices
Imports Autodesk.Revit.Attributes

<TransactionAttribute(TransactionMode.Manual)>
<RegenerationAttribute(RegenerationOption.Manual)>
Public Class Lab1PlaceGroup
    Implements Autodesk.Revit.UI.IExternalCommand

    Public Function Execute(commandData As ExternalCommandData, ByRef message As String, elements As ElementSet) As Result Implements IExternalCommand.Execute
        Dim uiApp As UIApplication = commandData.Application
        Dim doc As Document = uiApp.ActiveUIDocument.Document
        Dim pickRef As Reference = Nothing
        Dim sel As Selection = uiApp.ActiveUIDocument.Selection
        pickRef = sel.PickObject(ObjectType.Element, "Please select a group")
        Dim elem As Element = doc.GetElement(pickRef)
        Dim group As Group = elem

        Dim point As XYZ = sel.PickPoint("Please pick a point to place group")

        Dim trans As Transaction = New Transaction(doc)
        trans.Start("Lab")
        doc.Create.PlaceGroup(point, group.GroupType)
        trans.Commit()

        Return Result.Succeeded
    End Function
End Class

 

0 Likes
Accepted solutions (2)
2,516 Views
10 Replies
Replies (10)
Message 2 of 11

stever66
Advisor
Advisor

I don't really know Vb.  But if your code is right, make sure your .addin file is pointing to the right file name and location.

Message 3 of 11

JFN_KSH
Advocate
Advocate

My .addin is pointing to the bin/debug folder (not the release folder). But all seems to be fine.... I'm still looking... thanks!

0 Likes
Message 4 of 11

stever66
Advisor
Advisor

You might try C# since that's what the tutorial uses.  It also seems like most people using the Revit API are using C#.  And most of the examples seem to be in C#.

 

You can always convert it back to VB once you get it working.

0 Likes
Message 5 of 11

FaustoMendezcom
Enthusiast
Enthusiast

To troubleshoot your addin file

 

 

paste this on you addin file:

 

<?xml version="1.0" encoding="utf-8"?>
<RevitAddIns>
  <AddIn Type="Command">    
    <Assembly>Lab1PlaceGroup.dll</Assembly>
    <ClientId>502fe383-2648-4e98-adf8-5e6047f9dc34</ClientId>
    <FullClassName>Lab1PlaceGroup</FullClassName>
    <Text>Lab1PlaceGroup</Text>
    <VendorId>ADSK</VendorId>
    <VisibilityMode>AlwaysVisible</VisibilityMode>
  </AddIn>
</RevitAddIns>

and place your DLL (Lab1PlaceGroup.dll)

in the same folder .

Hope it helps 🙂
-------------------------------------------------------------------------------------
www.faustomendez.com
0 Likes
Message 6 of 11

JFN_KSH
Advocate
Advocate
Accepted solution

Ok.. I just got it working... (I am now trying the Hello world tutorial). I had to remove the namespace statement from my VB code... Which was translated from an internet site. Thanks a bunch to all!!

Imports System
Imports Autodesk.Revit.UI
Imports Autodesk.Revit.DB



<Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)>
    Public Class Class1
        Implements IExternalCommand

        Public Function Execute(commandData As ExternalCommandData, ByRef message As String, elements As ElementSet) As Result Implements IExternalCommand.Execute
            TaskDialog.Show("Revit", "Hello World")
            Return Autodesk.Revit.UI.Result.Succeeded
        End Function
    End Class

Capture.JPG

0 Likes
Message 7 of 11

stever66
Advisor
Advisor

Glad you got it working.

 

I may have missed it but I didn't see a namespace in your code.  Also I'm not sure what you had in your addin file, but if there is a namespace, the addin file has to refer to the entry point as;

 

<FullClassName>MyNamespace.Lab1PlaceGroup</FullClassName>

 

where you put your actual namespace name in for MyNamespace.

0 Likes
Message 8 of 11

JFN_KSH
Advocate
Advocate

Thanks, I guess you're right... I do not see any Namespace in my previous pasted code... I'm having a lot of trouble with that .addin manifest... Now I have to figure out why I can't debug... Visual studio just doesn't seem to be capable of starting Revit 2018... 

0 Likes
Message 9 of 11

stever66
Advisor
Advisor

You have to use the "step-into" on the revit Macros dialog box.

 

You can't use the "step-into" command inside the Sharp editor.

 

If that still doesn't work - search this forum.  There was a recent post with that problem and a solution by unloading other addins.

Message 10 of 11

JFN_KSH
Advocate
Advocate
Accepted solution

I just found last night my  answer as to why I could not debug.... I had to enable the Used managed compatibility mode in visual studio. As mentioned on this previous thread:https://forums.autodesk.com/t5/revit-api-forum/advice-on-debugging-c-in-visual-studio/m-p/6496811/hi.... Now I'm on my way... Thanks to all!!! 

0 Likes
Message 11 of 11

stever66
Advisor
Advisor

Right, that's a common issue with the newer VS.

 

I'm not sure why I thought you were using the Sharp Macro editor.....

 

 

0 Likes