-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathViewLintelsCommand.cs
More file actions
52 lines (42 loc) · 1.74 KB
/
Copy pathViewLintelsCommand.cs
File metadata and controls
52 lines (42 loc) · 1.74 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
using System;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using dosymep.Bim4Everyone;
using RevitLintelPlacement.Models;
using RevitLintelPlacement.ViewModels;
using RevitLintelPlacement.Views;
namespace RevitLintelPlacement;
[Transaction(TransactionMode.Manual)]
public class ViewLintelsCommand : BasePluginCommand {
public ViewLintelsCommand() {
PluginName = "Расстановщик перемычек";
}
protected override void Execute(UIApplication uiApplication) {
var activeView = uiApplication.ActiveUIDocument.ActiveGraphicalView;
if(!(activeView.ViewType == ViewType.ThreeD
|| activeView.ViewType == ViewType.Schedule
|| activeView.ViewType == ViewType.FloorPlan)) {
throw new Exception("Откройте 3Д вид, план этажа или спецификацию.");
}
var lintelsConfig = LintelsConfig.GetLintelsConfig();
var revitRepository = new RevitRepository(
uiApplication.Application,
uiApplication.ActiveUIDocument.Document,
lintelsConfig);
if(!HasConfig(revitRepository.LintelsCommonConfig)) {
return;
}
var elementInfos = new ElementInfosViewModel(revitRepository);
var lintelsView = new LintelCollectionViewModel(revitRepository, elementInfos);
var view = new LintelsView { DataContext = lintelsView };
view.Show();
}
private bool HasConfig(LintelsCommonConfig lintelsConfig) {
if(lintelsConfig.IsEmpty()) {
TaskDialog.Show("BIM", "Необходимо заполнить настройки плагина");
return false;
}
return true;
}
}