Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions src/RevitRoundingOfAreas/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

using Autodesk.Revit.DB;

using dosymep.Bim4Everyone;
using dosymep.Revit;
using dosymep.SimpleServices;
using dosymep.WPF.Commands;
Expand Down Expand Up @@ -133,21 +134,32 @@ private IEnumerable<ParamViewModel> GetSourceParamViewModels() {

// Метод получения коллекции ParamViewModel для TargetParams
private IEnumerable<ParamViewModel> GetTargetParamViewModels() {
var spatialElements = _revitRepository.GetAllSpatialElements().ToList();

return _paramService.AllRevitParams
.Where(revitParam => {
var spatialElements = _revitRepository.GetAllSpatialElements();
var randomSpatialElement = spatialElements.FirstOrDefault();
if(randomSpatialElement is null) {
return false;
}
var param = revitParam.GetParam(randomSpatialElement);
return !param.IsReadOnly;
if (!spatialElements.Any())
return true;

return spatialElements.All(spatialElement =>
TryGetParam(revitParam, spatialElement, out var param) && !param.IsReadOnly);
})
.Select(param => new ParamViewModel {
Name = param.Name,
RevitParam = param
});
}

// Метод получения параметра по RevitParam и Element
private static bool TryGetParam(RevitParam revitParam, Element element, out Parameter param) {
try {
param = revitParam.GetParam(element);
return param != null;
} catch {
param = null;
return false;
}
}

// Метод получения коллекции PhaseViewModel для Phases
private IEnumerable<PhaseViewModel> GetPhaseViewModels() {
Expand Down
Loading