: IExternalEventHandler
10 | {
11 | private readonly object _lock;
12 | private TType _savedArgs;
13 | private readonly ExternalEvent _revitEvent;
14 |
15 | ///
16 | /// Class for wrapping methods for execution within a "valid" Revit API context.
17 | ///
18 | protected RevitEventWrapper()
19 | {
20 | _revitEvent = ExternalEvent.Create(this);
21 | _lock = new object();
22 | }
23 |
24 | ///
25 | /// Wraps the "Execution" method in a valid Revit API context.
26 | ///
27 | /// Revit UI Application to use as the "wrapper" API context.
28 | public void Execute(UIApplication app)
29 | {
30 | TType args;
31 |
32 | lock (_lock)
33 | {
34 | args = _savedArgs;
35 | _savedArgs = default;
36 | }
37 |
38 | Execute(app, args);
39 | }
40 |
41 | ///
42 | /// Get the name of the operation.
43 | ///
44 | /// Operation Name.
45 | public string GetName()
46 | {
47 | return GetType().Name;
48 | }
49 |
50 | ///
51 | /// Execute the wrapped external event in a valid Revit API context.
52 | ///
53 | /// Arguments that could be passed to the execution method.
54 | public void Raise(TType args)
55 | {
56 | lock (_lock)
57 | {
58 | _savedArgs = args;
59 | }
60 |
61 | _revitEvent.Raise();
62 | }
63 |
64 | ///
65 | /// Override void which wraps the "Execution" method in a valid Revit API context.
66 | ///
67 | /// Revit UI Application to use as the "wrapper" API context.
68 | /// Arguments that could be passed to the execution method.
69 | public abstract void Execute(UIApplication app, TType args);
70 | }
71 | }
--------------------------------------------------------------------------------
/Revit Template/RevitTemplate.addin:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Revit Template Application
5 | RevitTemplate.dll
6 | 604b1052-f742-4127-8576-c821d1193102
7 | RevitTemplate.App
8 | Petr Mitev
9 | https://github.com/mitevpi
10 |
11 |
--------------------------------------------------------------------------------
/Revit Template/UI.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
28 |
29 |
30 |
31 |
32 |
33 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
43 |
44 |
45 |
46 |
47 |
48 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
58 |
59 |
60 |
61 |
62 |
64 |
66 |
68 |
70 |
72 |
74 |
76 |
78 |
80 |
82 |
83 |
84 |
85 |
86 |
87 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
97 |
99 |
100 |
101 |
103 |
104 |
105 |
106 |
107 |
123 |
124 |
125 |
127 |
128 |
129 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
146 |
148 |
150 |
152 |
153 |
154 |
156 |
157 |
158 |
160 |
161 |
162 |
163 |
164 |
179 |
193 |
196 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
--------------------------------------------------------------------------------
/Revit Template/UI.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows;
3 | using Autodesk.Revit.DB;
4 | using Autodesk.Revit.UI;
5 |
6 | namespace RevitTemplate
7 | {
8 | ///
9 | /// Interaction logic for UI.xaml
10 | ///
11 | public partial class Ui : Window
12 | {
13 | private readonly Document _doc;
14 |
15 | //private readonly UIApplication _uiApp;
16 | //private readonly Autodesk.Revit.ApplicationServices.Application _app;
17 | private readonly UIDocument _uiDoc;
18 |
19 | private readonly EventHandlerWithStringArg _mExternalMethodStringArg;
20 | private readonly EventHandlerWithWpfArg _mExternalMethodWpfArg;
21 |
22 | public Ui(UIApplication uiApp, EventHandlerWithStringArg evExternalMethodStringArg,
23 | EventHandlerWithWpfArg eExternalMethodWpfArg)
24 | {
25 | _uiDoc = uiApp.ActiveUIDocument;
26 | _doc = _uiDoc.Document;
27 | //_app = _doc.Application;
28 | //_uiApp = _doc.Application;
29 | Closed += MainWindow_Closed;
30 |
31 | InitializeComponent();
32 | _mExternalMethodStringArg = evExternalMethodStringArg;
33 | _mExternalMethodWpfArg = eExternalMethodWpfArg;
34 | }
35 |
36 |
37 | private void MainWindow_Closed(object sender, EventArgs e)
38 | {
39 | Close();
40 | }
41 |
42 | #region External Project Methods
43 |
44 | private void BExtString_Click(object sender, RoutedEventArgs e)
45 | {
46 | // Raise external event with a string argument. The string MAY
47 | // be pulled from a Revit API context because this is an external event
48 | _mExternalMethodStringArg.Raise($"Title: {_doc.Title}");
49 | }
50 |
51 | private void BExternalMethod1_Click(object sender, RoutedEventArgs e)
52 | {
53 | // Raise external event with this UI instance (WPF) as an argument
54 | _mExternalMethodWpfArg.Raise(this);
55 | }
56 |
57 | #endregion
58 |
59 | #region Non-External Project Methods
60 |
61 | private void UserAlert()
62 | {
63 | //TaskDialog.Show("Non-External Method", "Non-External Method Executed Successfully");
64 | MessageBox.Show("Non-External Method Executed Successfully", "Non-External Method");
65 |
66 | //Dispatcher.Invoke(() =>
67 | //{
68 | // TaskDialog mainDialog = new TaskDialog("Non-External Method")
69 | // {
70 | // MainInstruction = "Hello, Revit!",
71 | // MainContent = "Non-External Method Executed Successfully",
72 | // CommonButtons = TaskDialogCommonButtons.Ok,
73 | // FooterText = ""
74 | // + "Click here for the Revit API Developer Center"
75 | // };
76 |
77 |
78 | // TaskDialogResult tResult = mainDialog.Show();
79 | // Debug.WriteLine(tResult.ToString());
80 | //});
81 | }
82 |
83 | private void BNonExternal3_Click(object sender, RoutedEventArgs e)
84 | {
85 | // the sheet takeoff + delete method won't work here because it's not in a valid Revit api context
86 | // and we need to do a transaction
87 | // Methods.SheetRename(this, _doc); <- WON'T WORK HERE
88 | UserAlert();
89 | }
90 |
91 | private void BNonExternal1_Click(object sender, RoutedEventArgs e)
92 | {
93 | Methods.DocumentInfo(this, _doc);
94 | UserAlert();
95 | }
96 |
97 | private void BNonExternal2_Click(object sender, RoutedEventArgs e)
98 | {
99 | Methods.WallInfo(this, _doc);
100 | UserAlert();
101 | }
102 |
103 | #endregion
104 | }
105 | }
--------------------------------------------------------------------------------
/Revit Template/Util.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using System.Threading;
4 |
5 | namespace RevitTemplate
6 | {
7 | public static class Util
8 | {
9 | public static void LogThreadInfo(string name = "")
10 | {
11 | Thread th = Thread.CurrentThread;
12 | Debug.WriteLine($"Task Thread ID: {th.ManagedThreadId}, Thread Name: {th.Name}, Process Name: {name}");
13 | }
14 |
15 | public static void HandleError(Exception ex)
16 | {
17 | Debug.WriteLine(ex.Message);
18 | Debug.WriteLine(ex.Source);
19 | Debug.WriteLine(ex.StackTrace);
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/assets/refactor-instructions Page 001.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mitevpi/revit-wpf-template/58b0744fe0560ba2c59b4e1b0f1087c83ffac43c/assets/refactor-instructions Page 001.png
--------------------------------------------------------------------------------
/assets/refactor-instructions Page 002.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mitevpi/revit-wpf-template/58b0744fe0560ba2c59b4e1b0f1087c83ffac43c/assets/refactor-instructions Page 002.png
--------------------------------------------------------------------------------
/assets/refactor-instructions Page 003.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mitevpi/revit-wpf-template/58b0744fe0560ba2c59b4e1b0f1087c83ffac43c/assets/refactor-instructions Page 003.png
--------------------------------------------------------------------------------
/assets/refactor-instructions Page 004.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mitevpi/revit-wpf-template/58b0744fe0560ba2c59b4e1b0f1087c83ffac43c/assets/refactor-instructions Page 004.png
--------------------------------------------------------------------------------
/assets/refactor-instructions Page 005.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mitevpi/revit-wpf-template/58b0744fe0560ba2c59b4e1b0f1087c83ffac43c/assets/refactor-instructions Page 005.png
--------------------------------------------------------------------------------
/assets/refactor-instructions Page 006.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mitevpi/revit-wpf-template/58b0744fe0560ba2c59b4e1b0f1087c83ffac43c/assets/refactor-instructions Page 006.png
--------------------------------------------------------------------------------
/assets/refactor-instructions.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mitevpi/revit-wpf-template/58b0744fe0560ba2c59b4e1b0f1087c83ffac43c/assets/refactor-instructions.pdf
--------------------------------------------------------------------------------
/assets/ribbon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mitevpi/revit-wpf-template/58b0744fe0560ba2c59b4e1b0f1087c83ffac43c/assets/ribbon.png
--------------------------------------------------------------------------------
/assets/window1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mitevpi/revit-wpf-template/58b0744fe0560ba2c59b4e1b0f1087c83ffac43c/assets/window1.png
--------------------------------------------------------------------------------
/assets/window2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mitevpi/revit-wpf-template/58b0744fe0560ba2c59b4e1b0f1087c83ffac43c/assets/window2.png
--------------------------------------------------------------------------------
/assets/window3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mitevpi/revit-wpf-template/58b0744fe0560ba2c59b4e1b0f1087c83ffac43c/assets/window3.png
--------------------------------------------------------------------------------
/docs/Help/HelpLibraryManagerLauncher.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mitevpi/revit-wpf-template/58b0744fe0560ba2c59b4e1b0f1087c83ffac43c/docs/Help/HelpLibraryManagerLauncher.exe
--------------------------------------------------------------------------------
/docs/Help/Install_Revit WPF Template Documentation.bat:
--------------------------------------------------------------------------------
1 | @ECHO OFF
2 | CLS
3 |
4 | REM This is an example script to show how to use the Help Library Manager Launcher to install an MS Help Viewer
5 | REM file. You can use this as an example for creating a script to run from your product's installer.
6 |
7 | REM NOTE: If not executed from within the same folder as the executable, a full path is required on the
8 | REM executable and the HelpContentSetup.msha file.
9 |
10 | IF "%1%"=="" GOTO MissingVersion
11 | IF "%1%"=="1.0" GOTO HelpViewer1
12 |
13 | GOTO HelpViewer2:
14 |
15 | :HelpViewer1
16 |
17 | REM Help Viewer 1.0
18 | REM Uninstall first in case it is already there. If not, it won't install below. We'll ignore any error output
19 | REM by redirecting it to NUL.
20 | HelpLibraryManagerLauncher.exe /product "VS" /version "100" /locale en-us /uninstall /silent /vendor "Vendor Name" /productName "Revit WPF Template" /mediaBookList "Revit WPF Template" > NUL
21 |
22 | REM For Help Viewer 1.0. the setup name must be HelpContentSetup.msha so make sure we copy the setup file to that
23 | REM name. SHFB names it after the help file so that multiple files can be deployed to the same output older at
24 | REM build time.
25 | IF EXIST "Revit WPF Template Documentation.msha" COPY /Y "Revit WPF Template Documentation.msha" HelpContentSetup.msha
26 |
27 | REM Install the new content.
28 | HelpLibraryManagerLauncher.exe /product "VS" /version "100" /locale en-us /sourceMedia "%CD%\HelpContentSetup.msha"
29 |
30 | GOTO Exit
31 |
32 | :HelpViewer2
33 |
34 | REM Help Viewer 2.x
35 | REM Uninstall first in case it is already there. If not, it won't install below. We'll ignore any error output
36 | REM by redirecting it to NUL.
37 | HelpLibraryManagerLauncher.exe /viewerVersion %1 /locale en-us /wait 0 /operation uninstall /vendor "Vendor Name" /productName "Revit WPF Template" /bookList "Revit WPF Template" > NUL
38 |
39 | REM Install the new content.
40 | HelpLibraryManagerLauncher.exe /viewerVersion %1 /locale en-us /wait 0 /operation install /sourceUri "%CD%\Revit WPF Template Documentation.msha"
41 |
42 | GOTO Exit
43 |
44 | :MissingVersion
45 | ECHO A help viewer version parameter is required
46 |
47 | :Exit
48 |
--------------------------------------------------------------------------------
/docs/Help/Remove_Revit WPF Template Documentation.bat:
--------------------------------------------------------------------------------
1 | @ECHO OFF
2 | CLS
3 |
4 | REM This is an example script to show how to use the Help Library Manager Launcher to remove an MS Help Viewer file.
5 | REM You can use this as an example for creating a script to run from your product's uninstaller.
6 |
7 | REM NOTE: If not executed from within the same folder as the executable, a full path is required on the executable.
8 |
9 | IF "%1%"=="" GOTO MissingVersion
10 | IF "%1%"=="1.0" GOTO HelpViewer1
11 |
12 | GOTO HelpViewer2
13 |
14 | :HelpViewer1
15 |
16 | REM Help Viewer 1.0
17 | HelpLibraryManagerLauncher.exe /product "VS" /version "100" /locale en-us /uninstall /silent /vendor "Vendor Name" /productName "Revit WPF Template" /mediaBookList "Revit WPF Template"
18 |
19 | GOTO Exit
20 |
21 | :HelpViewer2
22 |
23 | REM Help Viewer 2.x
24 | HelpLibraryManagerLauncher.exe /viewerVersion %1 /locale en-us /wait 0 /operation uninstall /vendor "Vendor Name" /productName "Revit WPF Template" /bookList "Revit WPF Template"
25 |
26 | GOTO Exit
27 |
28 | :MissingVersion
29 | ECHO A help viewer version parameter is required
30 |
31 | :Exit
32 |
--------------------------------------------------------------------------------
/docs/Help/Revit WPF Template Documentation.chm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mitevpi/revit-wpf-template/58b0744fe0560ba2c59b4e1b0f1087c83ffac43c/docs/Help/Revit WPF Template Documentation.chm
--------------------------------------------------------------------------------
/docs/Help/Revit WPF Template Documentation.msha:
--------------------------------------------------------------------------------
1 |
2 |
3 | Revit WPF Template
4 |
5 |
6 |
7 | Vendor Name
8 | en-us
9 | Revit WPF Template
10 | Revit WPF Template
11 |
12 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/docs/Help/Revit WPF Template Documentation.mshc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mitevpi/revit-wpf-template/58b0744fe0560ba2c59b4e1b0f1087c83ffac43c/docs/Help/Revit WPF Template Documentation.mshc
--------------------------------------------------------------------------------
/docs/Help/SearchHelp.aspx:
--------------------------------------------------------------------------------
1 | <%@ Page Language="C#" EnableViewState="False" %>
2 |
3 |
234 |
--------------------------------------------------------------------------------
/docs/Help/Web.Config:
--------------------------------------------------------------------------------
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 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/docs/Help/WebKI.xml:
--------------------------------------------------------------------------------
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 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
--------------------------------------------------------------------------------
/docs/Help/WebTOC.xml:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/docs/Help/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
9 | Revit WPF Template - Redirect
10 |
11 |
12 | If you are not redirected automatically, follow this link to the default topic.
13 |
14 |
15 |
--------------------------------------------------------------------------------
/docs/Help/search.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Revit WPF Template - Search
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
15 |
16 |
17 |
18 |
23 |
24 |
25 | Sort by title
26 |
27 |
28 |
29 |
30 |
31 | Back
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/docs/RefactorInstructions.md:
--------------------------------------------------------------------------------
1 | # Refactor Instructions
2 |
3 | 
4 | 
5 | 
6 | 
7 | 
8 | 
--------------------------------------------------------------------------------
/docs/RevitTemplate.shfbproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
6 | Debug
7 | AnyCPU
8 | 2.0
9 | {5e0e2b63-96a1-4b2b-a0c7-8097a8aa16a5}
10 | 2017.9.26.0
11 |
12 | Documentation
13 | Documentation
14 | Documentation
15 |
16 | .NET Framework 4.5
17 | .\Help\
18 | Revit WPF Template Documentation
19 | en-US
20 |
21 |
22 |
23 | HtmlHelp1, MSHelpViewer, Website
24 | Standard
25 | VS2013
26 | True
27 | True
28 | False
29 | False
30 | OnlyWarningsAndErrors
31 | Revit WPF Template
32 | 1.0.0.0
33 | MemberName
34 | False
35 | False
36 | False
37 | Blank
38 | https://github.com/mitevpi
39 | p.mitevpi%40gmail.com
40 | InheritedMembers, InheritedFrameworkMembers, Privates, PrivateFields, Protected, ProtectedInternalAsProtected, NonBrowsable
41 |
42 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
64 |
65 |
66 |
67 |
68 |
69 | OnBuildSuccess
70 |
71 |
72 |
73 | ..\..\stenotype-internal\Stenotype\Revit Binaries\RevitAPI.dll
74 |
75 |
76 | ..\..\stenotype-internal\Stenotype\Revit Binaries\RevitAPIUI.dll
77 |
78 |
79 |
--------------------------------------------------------------------------------