-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.cs
83 lines (65 loc) · 2.73 KB
/
App.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#region Namespaces
using System;
using System.Collections.Generic;
using System.IO;
using System.Windows.Media.Imaging;
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using System.Resources;
#endregion
namespace RoomsToTopoJson
{
class App : IExternalApplication
{
public Result OnStartup(UIControlledApplication application)
{
// Get the absolut path of this assembly
string ExecutingAssemblyPath = System.Reflection.Assembly.GetExecutingAssembly(
).Location;
// Create a ribbon panel
RibbonPanel m_projectPanel = application.CreateRibbonPanel(
"RoomsToTopoJson");
//Button
PushButton pushButton = m_projectPanel.AddItem(new PushButtonData(
"RoomsToTopoJson", "RoomsToTopoJson", ExecutingAssemblyPath,
"RoomsToTopoJson.Main")) as PushButton;
//Add Help ToolTip
pushButton.ToolTip = "RoomsToTopoJson";
//Add long description
pushButton.LongDescription =
"This addin exports room boundaries to TopoJson";
// Set the large image shown on button.
pushButton.LargeImage = PngImageSource(
"RoomsToTopoJson.Resources.RoomsToTopoJson.png");
// Get the location of the solution DLL
string path = System.IO.Path.GetDirectoryName(
System.Reflection.Assembly.GetExecutingAssembly().Location);
// Combine path with \
string newpath = Path.GetFullPath(Path.Combine(path, @"..\"));
// Set the contextual help to point Help.html
//ContextualHelp contextHelp = new ContextualHelp(
// ContextualHelpType.ChmFile,
// newpath + "Resources\\Help.html");
ContextualHelp contextHelp = new ContextualHelp(
ContextualHelpType.Url,
"https://engworks.com/renumber-parts/");
// Assign contextual help to pushbutton
pushButton.SetContextualHelp(contextHelp);
return Result.Succeeded;
}
private System.Windows.Media.ImageSource PngImageSource(string embeddedPath)
{
// Get Bitmap from Resources folder
Stream stream = this.GetType().Assembly.GetManifestResourceStream(embeddedPath);
var decoder = new System.Windows.Media.Imaging.PngBitmapDecoder(stream,
BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
return decoder.Frames[0];
}
public Result OnShutdown(UIControlledApplication a)
{
return Result.Succeeded;
}
}
}