-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIsolateParameter_1
76 lines (61 loc) · 2.24 KB
/
IsolateParameter_1
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.Threading.Tasks;
using Autodesk.Revit.DB;
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
using System.Collections;
namespace IsolateParameter
{
[Transaction(TransactionMode.Manual)]
[Regeneration(RegenerationOption.Manual)]
public class sop_IsolateParameter : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
//Get application and documetn objects
UIApplication uiapp = commandData.Application;
UIDocument uidoc = uiapp.ActiveUIDocument;
Document doc = uidoc.Document;
Application app = uiapp.Application;
using (Transaction t = new Transaction(doc, "sop_IsolateParameter"))
{
t.Start("sop_IsolateParameter");
try
{
View view = uidoc.ActiveView;
// all elements in active view
var collector = new FilteredElementCollector(doc, view.Id).WhereElementIsNotElementType();
List<Element> elementsInView = new List<Element>();
foreach (Element e in collector)
{
if (null != e.Category
&& e.Category.HasMaterialQuantities)
{
elementsInView.Add(e);
}
}
//Create UserWindowControl
UserWindControl userWindControl = new UserWindControl(elementsInView, view, uidoc);
userWindControl.Show();
}
catch (Autodesk.Revit.Exceptions.OperationCanceledException)
{
return Result.Cancelled;
}
catch (Exception ex)
{
message = ex.Message;
return Result.Failed;
}
t.Commit();
}
return Result.Succeeded;
}
}
}