Macro into a NewAddInId

Macro into a NewAddInId

Anonymous
Not applicable
451 Views
3 Replies
Message 1 of 4

Macro into a NewAddInId

Anonymous
Not applicable

I am trying to turn my macro into an "External Tools" Addin button but while adding the code to implement the IExternalCommand and I am doing something wrong. Below colored red are my errors in visual studio. Any help would be greatly appreciated.

 

namespace AlignViews
{
    [Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]

    public partial class ThisDocument : IExternalCommand
    {
        static AddInId appId = new AddInId(new System.Guid("7BD4FE06-702E-4A54-88B0-A70EFD65F60B")
        public void Result Execute(ExternalCommandData commandData, ref string message, ElementSet elementSet)
        {
            // Get the current document
            Document curDoc = this.Application.ActiveUIDocument.Document;

 

0 Likes
452 Views
3 Replies
Replies (3)
Message 2 of 4

j.buijs
Enthusiast
Enthusiast

What do the errors say? This snippet of code looks good to me.

0 Likes
Message 3 of 4

stever66
Advisor
Advisor

In Visual Studio, have you added the references to RevitAPI.dll and and the RevitUIAPI.dll?  (I may have the exact names wrong.)

 

And have you added the typical "using" statements?

0 Likes
Message 4 of 4

jeremytammik
Autodesk
Autodesk

Dear Simon,

 

The code looks OK to me too.

 

I would suggest you work through the Revit API getting started material and create a new add-in from scratch first:

 

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

 

Once you have that up and running, you will understand all the basic concepts and it will be easier for you to migrate the existing macro.

 

Best regards, good luck, and have fun,

 

Jeremy

 



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

0 Likes