-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmacro.cs
66 lines (59 loc) · 2.21 KB
/
macro.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
using System;
using Autodesk.Revit.UI;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI.Selection;
using System.Collections.Generic;
using System.Linq;
using System.Collections.ObjectModel;
using System.Diagnostics;
namespace LinePatternMacro
{
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
[Autodesk.Revit.DB.Macros.AddInId("E06D5119-8BFF-4870-B19D-B546347DBD47")]
public partial class ThisApplication
{
private void Module_Startup(object sender, EventArgs e)
{
}
private void Module_Shutdown(object sender, EventArgs e)
{
}
#region Revit Macros generated code
private void InternalStartup()
{
this.Startup += new System.EventHandler(Module_Startup);
this.Shutdown += new System.EventHandler(Module_Shutdown);
}
#endregion
public void LinePatternViewer()
{
LPMainWindow main_win = null;
try
{
Document theDoc = this.ActiveUIDocument.Document;
System.Collections.ObjectModel.ObservableCollection<LinePattern> data =
new System.Collections.ObjectModel.ObservableCollection<LinePattern>();
//Collect all line pattern elements
FilteredElementCollector collector = new FilteredElementCollector(theDoc);
IList<Element> linepatternelements = collector.WherePasses(new ElementClassFilter(typeof(LinePatternElement))).ToElements();
foreach (LinePatternElement lpe in linepatternelements)
{
data.Add(lpe.GetLinePattern());
}
//start main window
main_win = new LinePatternMacro.LPMainWindow(data);
System.Windows.Interop.WindowInteropHelper x = new System.Windows.Interop.WindowInteropHelper(main_win);
x.Owner = Process.GetCurrentProcess().MainWindowHandle;
main_win.ShowDialog();
}
catch (Exception err)
{
Debug.WriteLine(new string('*', 100));
Debug.WriteLine(err.ToString());
Debug.WriteLine(new string('*', 100));
if (main_win != null && main_win.IsActive)
main_win.Close();
}
}
}
}