-
Notifications
You must be signed in to change notification settings - Fork 11
/
PickFace.cs
54 lines (49 loc) · 1.63 KB
/
PickFace.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
using Application = Autodesk.Revit.ApplicationServices.Application;
namespace Day03
{
[Transaction(TransactionMode.Manual)]
[Regeneration(RegenerationOption.Manual)]
[Journaling(JournalingMode.UsingCommandData)]
public class PickFace : IExternalCommand
{
/// <summary>
/// Return Count Of Face Element
/// </summary>
/// <param name="commandData"></param>
/// <param name="message"></param>
/// <param name="elements"></param>
/// <returns></returns>
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
#region Init
UIApplication uiapp = commandData.Application;
UIDocument uidoc = uiapp.ActiveUIDocument;
Application app = uiapp.Application;
Document doc = uidoc.Document;
#endregion
try
{
IList<Reference> refs = uidoc.Selection.PickObjects(ObjectType.Face);
MessageBox.Show($"{refs.Count} Face");
}
catch (Autodesk.Revit.Exceptions.OperationCanceledException e)
{
MessageBox.Show($"You Has Press Esc\n{e}", "Warning", MessageBoxButtons.OK);
return Result.Cancelled;
//Pressed Esc
}
return Result.Succeeded;
}
}
}