-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCommand.cs
More file actions
53 lines (45 loc) · 1.64 KB
/
Command.cs
File metadata and controls
53 lines (45 loc) · 1.64 KB
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
using Autodesk.Revit.Attributes;
//
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using System.Windows.Forms;
using App = Autodesk.Revit.ApplicationServices;
namespace RevitExportTest
{
[Transaction(TransactionMode.ReadOnly)]
public class Command : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
UIApplication uiapp = commandData.Application;
UIDocument uidoc = uiapp.ActiveUIDocument;
App.Application app = uiapp.Application;
Document doc = uidoc.Document;
if (null == uidoc)
{
message = "Please run this command in an active project document.";
return Result.Failed;
}
View3D view = doc.ActiveView as View3D;
if (null == view)
{
message = "Please run this command in a 3D view.";
return Result.Failed;
}
SaveFileDialog sdial = new SaveFileDialog();
sdial.Filter = "gltf|*.gltf|glb|*.glb";
if (sdial.ShowDialog() == DialogResult.OK)
{
TestExportContext context = new TestExportContext(doc);
using (CustomExporter exporter = new CustomExporter(doc, context))
{
exporter.IncludeGeometricObjects = false;
exporter.Export(view);
context._model.SaveGLB(sdial.FileName);
context._model.SaveGLTF(sdial.FileName);
}
}
return Result.Succeeded;
}
}
}