AddRibbonPanel not workonh

AddRibbonPanel not workonh

GHASEM_ARIYANI
Advisor Advisor
645 Views
5 Replies
Message 1 of 6

AddRibbonPanel not workonh

GHASEM_ARIYANI
Advisor
Advisor

Hello

 

I'm trying to add new Ribbon, but not working my code.

please help me.

*************************************************

using System;
using System.Reflection;
using System.Windows.Media.Imaging;
using Autodesk.Revit.UI;
using Autodesk.Revit.DB;


namespace SelectElementsID
{
class SelectElids : IExternalApplication
{

static void AddRibbonPanel(UIControlledApplication application)
{
String tabName = "Select ID";
application.CreateRibbonTab(tabName);

RibbonPanel ribbonPanel = application.CreateRibbonPanel(tabName, "Tools");

string thisAssemblyPath = Assembly.GetExecutingAssembly().Location;

PushButtonData b1Date = new PushButtonData("cmdSelectElemetsID", "IDs" + System.Environment.NewLine
+ "ElemetsID ", thisAssemblyPath, "SelectElemetsID.SelectElids");

PushButton pb1 = ribbonPanel.AddItem(b1Date) as PushButton;
pb1.ToolTip = "show select elemets id";
BitmapImage pb1Image = new BitmapImage
(new Uri("pack://application:,,,/SelectElementsID;component/Resources/SelectElementsID.png"));
//pb1.ToolTipImage=

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

public Result OnStartup(UIControlledApplication application)
{
AddRibbonPanel(application);
return Result.Succeeded;
}
}
}

************************

 

<?xml version="1.0" encoding="utf-8"?>
<RevitAddIns>
<AddIn Type="Command">
<Assembly>SelectElementsID.dll</Assembly>
<ClientId>0c0425e1-81d6-45d6-b8ff-4bf100deb062</ClientId>
<FullClassName>SelectElemetsID.SelectElids.cs</FullClassName>
<Text>show id elements</Text>
<VendorId>TEST</VendorId>
<VisibilityMode>AlwaysVisible</VisibilityMode>
</AddIn>
</RevitAddIns>

 

2018-01-29_1-24-46.png

Please use " Accept as Solution", and give kudos as appropriate to further enhance these forums. Thank you!
0 Likes
Accepted solutions (2)
646 Views
5 Replies
Replies (5)
Message 2 of 6

jeremytammik
Autodesk
Autodesk
Accepted solution

Welcome to Revit API programming!

 

To get started with the Revit API, I suggest that you first of all take a look at the getting started material and work through the step-by-step instructions provided by the DevTV and My First Revit Plugin video tutorials:

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

 

That will explain all you need, including the answer to your question.

 

For a quick start, you can also check out the hello world examples in the developer guide:

 

http://help.autodesk.com/view/RVT/2018/ENU/?guid=Revit_API_Revit_API_Developers_Guide_Introduction_G...

 

Cheers,

 

Jeremy



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

Message 3 of 6

MarryTookMyCoffe
Collaborator
Collaborator
Accepted solution

you did mistake here
<FullClassName>SelectElemetsID.SelectElids.cs</FullClassName> it schould be a class name not a cs file in visual.

so SelectElementsID.SelectElids

 the namespace.className

here is link to a most detailed explanation how to make ribbon and button:
http://archi-lab.net/create-your-own-tab-and-buttons-in-revit/

 

 

 

 

-------------------------------------------------------------
--------------------------------|\/\/|------------------------
do not worry it only gonna take Autodesk 5 years to fix bug
Message 4 of 6

GHASEM_ARIYANI
Advisor
Advisor

Hello @jeremytammik

 

Thank you very much for your answer.

Please use " Accept as Solution", and give kudos as appropriate to further enhance these forums. Thank you!
0 Likes
Message 5 of 6

GHASEM_ARIYANI
Advisor
Advisor

Hello @MarryTookMyCoffe

 

Thank you very much for your answer.

Please use " Accept as Solution", and give kudos as appropriate to further enhance these forums. Thank you!
0 Likes
Message 6 of 6

GHASEM_ARIYANI
Advisor
Advisor

I use of the Revit APi Help link  :   http://help.autodesk.com/view/RVT/2018/ENU/?guid=Revit_API_Revit_API_Developers_Guide_Introduction_G...

 

 

but not working:

 

my code:

 

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


namespace Walkthrough
{

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

public class HelloWorld : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
TaskDialog.Show("Revit", "Hello World");
return Result.Succeeded;
}
}
public class CsAddPanel : IExternalApplication
{
public Result OnShutdown(UIControlledApplication application)
{
return Result.Succeeded;
}

public Result OnStartup(UIControlledApplication application)
{
RibbonPanel ribbonPanel = application.CreateRibbonPanel("NewRibbonPanel");
string thisAssemblyPath = Assembly.GetExecutingAssembly().Location;
PushButtonData buttonData = new PushButtonData("cmdHelloWotld"
,"Hello World", thisAssemblyPath,"Walkthrough.HelloWorld");

PushButton pushButton = ribbonPanel.AddItem(buttonData) as PushButton;

pushButton.ToolTip = "XXXXXXXXXXXXXXXXXXXXXX";


Uri uriImage = new Uri(@"C:\Users\Autodesk\Desktop\C#Exam\AddPanel\button.png");
BitmapImage largImage = new BitmapImage(uriImage);
pushButton.LargeImage = largImage;

return Result.Succeeded;
}
}
}

 

*****************************

 

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<RevitAddIns>
<AddIn Type="Command">
<Assembly>C:\Users\Autodesk\Desktop\C#Exam\AddPanel\AddPanel\bin\Debug\AddPanel.dll </Assembly>
<AddInId>9014ad4a-a611-49b6-89ec-9e1799695401</AddInId>
<FullClassName>Walkthrough.CsAddPanel</FullClassName>
<Text>HelloWorld</Text>
<VendorId>NAME</VendorId>
<VendorDescription>Your Company Information</VendorDescription>
</AddIn>
</RevitAddIns>

 

 

Please use " Accept as Solution", and give kudos as appropriate to further enhance these forums. Thank you!
0 Likes