Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

code for new ribbon

1 REPLY 1
Reply
Message 1 of 2
bthatcher
351 Views, 1 Reply

code for new ribbon

I'm trying to add a new ribbon panel. I used the hello world ribbon wank through from the wiki help. Here's what I have, it won't work. Any thoughts? Thanks.

 

 

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using Autodesk.Revit;

using System.Diagnostics;

using System.IO;

using System.Windows.Media;

using System.Windows.Forms;

using System.Windows.Media.Imaging;

using Autodesk.Revit.UI;

using Autodesk.Revit.DB;

using Autodesk.Revit.ApplicationServices;

using Autodesk.Revit.UI.Events;

 

namespace

AddPanel

{

   

publicclassAddpanel : Autodesk.Revit.UI.IExternalApplication

    {

   

public Autodesk.Revit.UI.Result OnStartup(UIControlledApplication application)

        {

           

// add new ribbon panel

         

RibbonPanel ribbonPanel = application.CreateRibbonPanel("NewRibbonPanel");

           

//Create a push button in the ribbon panel "NewRibbonPanel"

         

//the add-in application "HelloWorld" will be triggered when button is pushed

           

PushButton pushButton = ribbonPanel.AddItem(newPushButtonData("HelloWorld",

            

"HelloWorld", @"C:\Users\bthatcher\Documents\Visual Studio 2010\Projects\HelloWorld\HelloWorld\bin\Release\HelloWorld.dll", "HelloWorld.HelloWorld")) asPushButton;

           

// Set the large image shown on button


Uri uriImage = newUri(@"C:\Users\bthatcher\Desktop\CB.jpg");

           

BitmapImage largeImage = newBitmapImage(uriImage);

            pushButton.LargeImage = largeImage;

           

returnResult.Succeeded;

        }

       

publicResult OnShutdown(UIControlledApplication application)

        {

           

returnResult.Succeeded;

        }

    }

}

1 REPLY 1
Message 2 of 2
saikat
in reply to: bthatcher

Hi:

 

Could it be because you are missing the transaction and regeneration attributes for the class. You should be adding the following attributes like :

 

[Autodesk.Revit.Attributes.

Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]

[Autodesk.Revit.Attributes.

Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)]

[Autodesk.Revit.Attributes.

Journaling(Autodesk.Revit.Attributes.JournalingMode.NoCommandData)]

 

publicclassCommand : IExternalCommand

{

#region

IExternalCommand Members

. . .

 

Also please ensure that the entries in the addin manifest file are correct. If you need a ready made sample which creates a ribbon, please refer to the Ribbon sample which is part of the Revit SDK (which can be installed from the Revit installer under tools and utilities menu).

 

Hope this helps

Saikat

 



Saikat Bhattacharya
Senior Manager - Technology Consulting

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community