- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm just getting started with C# with visual studios and having issues getting the application to run. The command loads in fine on its own under the add-ins but if I try and put it under a panel I get a bunch of errors. I get two errors. First is the dubug:
Second is external tool failure:
Local Copy is set to False.
Below is the code I'm using for the App.cs
#region Namespaces
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using System;
using System.Collections.Generic;
#endregion
using System.Diagnostics;
using System.Windows.Media.Imaging;
using System.Reflection;
namespace TpMechanical
{
internal class App : IExternalApplication
{
public Result OnStartup(UIControlledApplication a)
{
//Note: Option 1.
String tabname = "TpMechanical";
String panelname = "Tools";
//Creating The Tab
a.CreateRibbonTab(tabname);
//Note:Tab Panel.
var Toolspanel = a.CreateRibbonPanel("tabname", "panelname");
//Note: creating The Buttons.
var button1 = new PushButtonData("TpMechanical button1", "Button 1", Assembly.GetExecutingAssembly().Location, "TpMechanical.Command");
button1.ToolTip = "Custom Set of TpMechanical Tools";
button1.LongDescription = "TpMechanical Tools are copyrited by TpMechanical";
var btn1 = Toolspanel.AddItem(button1) as PushButton;
//Note: Stacked Buttons.
var button2 = new PushButtonData("TpMechanical button2", "Button 2", Assembly.GetExecutingAssembly().Location, "TpMechanical.Command");
button2.ToolTip = "Custom Set of TpMechanical Tools";
button2.LongDescription = "TpMechanical Tools are copyrited by TpMechanical.";
var button3 = new PushButtonData("TpMechanical button3", "Button 3", Assembly.GetExecutingAssembly().Location, "TpMechanical.Command");
button3.ToolTip = "Custom Set of TpMechanical Tools";
button3.LongDescription = ("TpMechanical Tools are copyrited by TpMechanical, \n" +
"NO use of tools outside of the organization has been deemeed illegal & in violation of employment contract");
Toolspanel.AddStackedItems(button1 , button2, button3);
//Note: Option 2.
//RibbonPanel curPanel = a.CreateRibbonPanel("TpMechanical", "Tools");
//string curAssembly = System.Reflection.Assembly.GetExecutingAssembly().Location;
//string curAssemblyPath = System.IO.Path.GetDirectoryName(curAssembly);
//Note: Verify Revitapi, Revitapiui, & Presentationcore are active in References.
//PushButtonData pbd1 = new PushButtonData("All Text to UPPER", "All Text" + "\r" + "to UPPER", curAssembly, "TpMechanical.Command");
//PushButtonData pbd2 = new PushButtonData("All Text to lower", "All Text" + "\r" + "to lower", curAssembly, "TpMechanical.Command");
//PushButtonData pbd3 = new PushButtonData("All Text to UPPER", "All Text" + "\r" + "to UPPER", curAssembly, "TpMechanical.Command");
//PushButtonData pbd4 = new PushButtonData("All Text to lower", "All Text" + "\r" + "to lower", curAssembly, "TpMechanical.Command");
//pbd1.LargeImage = new BitmapImage(new Uri(System.IO.Path.Combine(curAssemblyPath, "1788592.png")));
//pbd2.LargeImage = new BitmapImage(new Uri(System.IO.Path.Combine(curAssemblyPath, "icon_1.png")));
//pbd3.LargeImage = new BitmapImage(new Uri(System.IO.Path.Combine(curAssemblyPath, "icon_1.png")));
//pbd4.LargeImage = new BitmapImage(new Uri(System.IO.Path.Combine(curAssemblyPath, "icon_1.png")));
//PushButton pb1 = (PushButton)curPanel.AddItem(pbd1);
//PushButton pb2 = (PushButton)curPanel.AddItem(pbd2);
//PushButton pb3 = (PushButton)curPanel.AddItem(pbd3);
//PushButton pb4 = (PushButton)curPanel.AddItem(pbd4);
return Result.Succeeded;
}
public Result OnShutdown(UIControlledApplication a)
{
return Result.Succeeded;
}
}
}
Solved! Go to Solution.