-
Notifications
You must be signed in to change notification settings - Fork 16
RevitRoundingOfAreas: Создан плагин для округления площадей (соц. объекты) #451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 14 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
1d569b1
Создан новый плагин RevitRoundingOfAreas
5a46e04
RevitRoundingOfAreas: добавление описание проекта, удаление лишней ло…
47a9ee0
RevitRoundingOfAreas: Создание класс основного окна
ef699f2
RevitRoundingOfAreas: Заполнение класса MaimViewModel
91ee91f
RevitRoundingOfAreas: Доработка View и ViewModel, добавление классов
b745310
RevitRoundingOfAreas: Исправление отступов кнопок в окне
97a66f8
RevitRoundingOfAreas: Добавление класса добавления параметра
a18ec3e
RevitRoundingOfAreas: Добавление класса по проверке помещений
1c5381e
RevitRoundingOfAreas: Доработка MainViewModel
12d8617
RevitRoundingOfAreas: Реализация предупреждений
1554939
RevitRoundingOfAreas: Исправление окна предупреждений
55565c2
RevitRoundingOfAreas: Добавление основных методов округления, рефакто…
188d20b
RevitRoundingOfAreas: Исправление локализации
fd1801f
RevitRoundingOfAreas: Небольшой рефакторинг кода, исправление названи…
ab96fec
RevitRoundingOfAreas: Применение фабрики параметров, получения значен…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| name: publish RevitRoundingOfAreas | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| pull_request: | ||
| types: [ closed, synchronize, review_requested ] | ||
| branches: [ main, master ] | ||
| paths: | ||
| - '**RevitRoundingOfAreas**.cs' | ||
| - '**RevitRoundingOfAreas**.xaml' | ||
|
|
||
| env: | ||
| plugin-name: "RevitRoundingOfAreas" | ||
|
|
||
| jobs: | ||
| build: | ||
| name: build | ||
| runs-on: windows-latest | ||
| steps: | ||
| - uses: actions/checkout@v3 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| # Install the .NET workload | ||
| - name: Install .NET | ||
| uses: actions/setup-dotnet@v4 | ||
| with: | ||
| dotnet-version: 8.0.x | ||
|
|
||
| # Add DevExrepress package source: https://nuget.devexpress.com/ | ||
| - name: Add DevExpress package source | ||
| run: dotnet nuget add source https://nuget.devexpress.com/api -n DXFeed -u DevExpress -p ${{ secrets.DEVEXPRESS_FEED_AUTHORIZATION_KEY }} | ||
|
|
||
| - name: Run './build.cmd ' | ||
| run: ./build.cmd publish --profile ${{ env.plugin-name }} --pull-request-merged ${{ github.event.pull_request.merged }} --extensions-app-token ${{ secrets.EXTENSIONS_APP_TOKEN }} --revit-plugins-app-token ${{ secrets.REVIT_PLUGINS_APP_TOKEN }} | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| { | ||
| "$schema": "./build.schema.json", | ||
| "Solution": "RevitPlugins.slnx", | ||
| "PluginName": "RevitRoundingOfAreas", | ||
| "PublishDirectory": "02.AR.extension\\АР.tab\\bin", | ||
| "RevitVersions": [ | ||
| "Rv2022", | ||
| "Rv2023", | ||
| "Rv2024" | ||
| ], | ||
| "IconUrl": "https://icons8.com/icon/79538/decrease-decimal", | ||
| "BundleName": "Рассчитать площади (соц. объекты)", | ||
| "BundleType": "InvokeButton", | ||
| "BundleOutput": "02.AR.extension\\АР.tab\\Квартирография.panel\\Помещения.pulldown" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| using Autodesk.Revit.ApplicationServices; | ||
| using Autodesk.Revit.DB; | ||
|
|
||
| using dosymep.Bim4Everyone.Templates; | ||
|
|
||
| namespace RevitRoundingOfAreas.Models; | ||
|
|
||
| internal class CheckProjectParams(SystemPluginConfig systemPluginConfig, Application application, Document document) { | ||
| private readonly ProjectParameters _projectParameters = ProjectParameters.Create(application); | ||
| private readonly bool _isChecked = true; | ||
|
|
||
| /// <summary> | ||
| /// Метод проверки загрузки параметров | ||
| /// </summary> | ||
| public bool GetIsChecked() { | ||
| return _isChecked; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Метод копирования параметров проекта | ||
| /// </summary> | ||
| public CheckProjectParams CopyProjectParams() { | ||
| _projectParameters.SetupRevitParams(document, systemPluginConfig.RoomAreaParam); | ||
| return this; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| using Autodesk.Revit.DB; | ||
|
|
||
| using dosymep.Bim4Everyone; | ||
|
|
||
| namespace RevitRoundingOfAreas.Models; | ||
|
|
||
| internal class ConfigSettings { | ||
| public ElementId SelectedPhaseId { get; set; } | ||
| public RevitParam SourceParam { get; set; } | ||
| public RevitParam TargetParam { get; set; } | ||
| public int Accuracy { get; set; } | ||
| } |
6 changes: 6 additions & 0 deletions
6
src/RevitRoundingOfAreas/Models/Enums/ElementsProviderType.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| namespace RevitRoundingOfAreas.Models.Enums; | ||
| internal enum ElementsProviderType { | ||
| AllElementsProvider, | ||
| CurrentViewProvider, | ||
| SelectedElementsProvider | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| namespace RevitRoundingOfAreas.Models.Enums; | ||
| internal enum WarningType { | ||
| NotEnclosed, | ||
| Redundant, | ||
| BrokenContour | ||
| } |
19 changes: 19 additions & 0 deletions
19
src/RevitRoundingOfAreas/Models/Factories/ProvidersFactory.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| using RevitRoundingOfAreas.Models.Enums; | ||
| using RevitRoundingOfAreas.Models.Interfaces; | ||
| using RevitRoundingOfAreas.Models.Providers; | ||
|
|
||
| namespace RevitRoundingOfAreas.Models.Factories; | ||
|
|
||
| internal class ProvidersFactory(RevitRepository revitRepository) { | ||
| /// <summary> | ||
| /// Метод получения провайдера элементов по Enum | ||
| /// </summary> | ||
| public IElementsProvider GetElementsProvider(ElementsProviderType type) { | ||
| return type switch { | ||
| ElementsProviderType.AllElementsProvider => new ElementsProviderAll(revitRepository), | ||
| ElementsProviderType.CurrentViewProvider => new ElementsProviderCurrentView(revitRepository), | ||
| ElementsProviderType.SelectedElementsProvider => new ElementsProviderSelected(revitRepository), | ||
| _ => new ElementsProviderAll(revitRepository) | ||
| }; | ||
| } | ||
| } |
18 changes: 18 additions & 0 deletions
18
src/RevitRoundingOfAreas/Models/Interfaces/IElementsProvider.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| using System.Collections.Generic; | ||
|
|
||
| using Autodesk.Revit.DB; | ||
|
|
||
| using RevitRoundingOfAreas.Models.Enums; | ||
|
|
||
| namespace RevitRoundingOfAreas.Models.Interfaces; | ||
|
|
||
| internal interface IElementsProvider { | ||
| /// <summary> | ||
| /// Тип провайдера элементов | ||
| /// </summary> | ||
| ElementsProviderType Type { get; } | ||
| /// <summary> | ||
| /// Метод получения элементов модели по стадиям | ||
| /// </summary> | ||
| List<SpatialModel> GetSpatialElements(ElementId phaseId); | ||
| } |
29 changes: 29 additions & 0 deletions
29
src/RevitRoundingOfAreas/Models/Interfaces/IWindowService.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| using System.Collections.Generic; | ||
|
|
||
| using RevitRoundingOfAreas.Models.Warnings; | ||
|
|
||
| namespace RevitRoundingOfAreas.Models.Interfaces; | ||
|
|
||
| internal interface IWindowService { | ||
| /// <summary> | ||
| /// Метод закрытия основного окна | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// В данном методе производится закрытие основного окна при появлении предупреждений | ||
| /// </remarks> | ||
| /// <returns> | ||
| /// Void. | ||
| /// </returns> | ||
| void CloseMainWindow(); | ||
| /// <summary> | ||
| /// Метод открытия окна. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// В данном методе производится открытие кона предупреждений для отображения WarningElement. | ||
| /// </remarks> | ||
| /// <param name="warningElements">Коллекция предупреждений WarningElement.</param> | ||
| /// <returns> | ||
| /// Void. | ||
| /// </returns> | ||
| void ShowWarningWindow(IReadOnlyCollection<WarningElement> warningElements); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
|
|
||
| using Autodesk.Revit.DB; | ||
|
|
||
| using dosymep.Bim4Everyone; | ||
| using dosymep.Bim4Everyone.ProjectParams; | ||
| using dosymep.Bim4Everyone.SharedParams; | ||
| using dosymep.Bim4Everyone.SystemParams; | ||
| using dosymep.Revit; | ||
|
|
||
| namespace RevitRoundingOfAreas.Models; | ||
|
|
||
| internal class ParamService { | ||
| private readonly RevitRepository _revitRepository; | ||
| private readonly SystemPluginConfig _systemPluginConfig; | ||
| private readonly ICollection<ElementId> _allParamElementIds; | ||
|
|
||
| public ParamService( | ||
| RevitRepository revitRepository, | ||
| SystemPluginConfig systemPluginConfig) { | ||
|
|
||
| _revitRepository = revitRepository; | ||
| _systemPluginConfig = systemPluginConfig; | ||
|
|
||
| _allParamElementIds = GetAllParamElementIds(); | ||
|
|
||
| AllRevitParams = GetAllRevitParams().AsReadOnly(); | ||
|
|
||
| DefaultSourceParam = GetDefaultSourceParam(); | ||
| DefaultTargetParam = GetDefaultTargetParam(); | ||
| } | ||
|
|
||
| public IReadOnlyList<RevitParam> AllRevitParams { get; } | ||
| public RevitParam DefaultSourceParam { get; } | ||
| public RevitParam DefaultTargetParam { get; } | ||
|
|
||
| private ICollection<ElementId> GetAllParamElementIds() { | ||
| var categoryId = new ElementId(BuiltInCategory.OST_Rooms); | ||
|
|
||
| return ParameterFilterUtilities | ||
| .GetFilterableParametersInCommon(_revitRepository.Document, [categoryId]); | ||
| } | ||
|
|
||
| private RevitParam GetDefaultSourceParam() { | ||
| return AllRevitParams | ||
| .OfType<SystemParam>() | ||
| .FirstOrDefault(x => x.SystemParamId == _systemPluginConfig.SystemRoomAreaParamId); | ||
| } | ||
|
|
||
| private RevitParam GetDefaultTargetParam() { | ||
| return AllRevitParams | ||
| .OfType<SharedParam>() | ||
| .FirstOrDefault(x => x.Name.Equals(_systemPluginConfig.RoomAreaParam.Name)); | ||
| } | ||
|
|
||
| private List<RevitParam> GetAllRevitParams() { | ||
| if(_allParamElementIds.Count == 0) { | ||
| return []; | ||
| } | ||
|
|
||
| List<RevitParam> parameters = []; | ||
|
|
||
| foreach(var elementId in _allParamElementIds) { | ||
| var revitParam = CreateRevitParam(elementId); | ||
|
|
||
| if(revitParam is null) { | ||
| continue; | ||
| } | ||
|
|
||
| if(IsSupportedStorageType(revitParam)) { | ||
| parameters.Add(revitParam); | ||
| } | ||
| } | ||
|
|
||
| return parameters; | ||
| } | ||
|
|
||
| private RevitParam CreateRevitParam(ElementId elementId) { | ||
| if(elementId.IsSystemId()) { | ||
| var builtInParameter = elementId.AsBuiltInParameter(); | ||
| return SystemParamsConfig.Instance.CreateRevitParam(_revitRepository.Document, builtInParameter); | ||
| } | ||
|
|
||
| var element = _revitRepository.Document.GetElement(elementId); | ||
|
|
||
| return element is null | ||
| ? null | ||
| : element is SharedParameterElement | ||
| ? SharedParamsConfig.Instance.CreateRevitParam(_revitRepository.Document, element.Name) | ||
| : ProjectParamsConfig.Instance.CreateRevitParam(_revitRepository.Document, element.Name); | ||
| } | ||
|
|
||
| private static bool IsSupportedStorageType(RevitParam revitParam) { | ||
| return revitParam.StorageType == StorageType.Double; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| using Autodesk.Revit.DB; | ||
|
|
||
| namespace RevitRoundingOfAreas.Models; | ||
|
|
||
| internal class PhaseModel { | ||
| public ElementId ElementId { get; set; } | ||
| public string Name { get; set; } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| using System; | ||
|
|
||
| using Autodesk.Revit.DB; | ||
|
|
||
| using dosymep.Bim4Everyone; | ||
| using dosymep.Bim4Everyone.ProjectConfigs; | ||
| using dosymep.Bim4Everyone.SharedParams; | ||
|
|
||
| using pyRevitLabs.Json; | ||
|
|
||
| namespace RevitRoundingOfAreas.Models; | ||
|
|
||
| internal class PluginConfig : ProjectConfig<RevitSettings> { | ||
|
|
||
| [JsonIgnore] | ||
| public override string ProjectConfigPath { get; set; } | ||
|
|
||
| [JsonIgnore] | ||
| public override IConfigSerializer Serializer { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Метод создания конфигурации плагина. | ||
| /// </summary> | ||
| /// <returns> | ||
| /// <param name="configSerializer">Сериализатор конфигурации.</param> | ||
| /// Возвращает прочитанную конфигурацию плагина, либо созданный конфиг по умолчанию. | ||
| /// </returns> | ||
| public static PluginConfig GetPluginConfig(IConfigSerializer configSerializer) { | ||
| return new ProjectConfigBuilder() | ||
| .SetSerializer(configSerializer) | ||
| .SetPluginName(nameof(RevitRoundingOfAreas)) | ||
| .SetRevitVersion(ModuleEnvironment.RevitVersion) | ||
| .SetProjectConfigName(nameof(PluginConfig) + ".json") | ||
| .Build<PluginConfig>(); | ||
| } | ||
| } | ||
|
|
||
| internal class RevitSettings : ProjectSettings { | ||
| /// <summary> | ||
| /// Наименование проекта. | ||
| /// </summary> | ||
| public override string ProjectName { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Выбранная стадия проекта | ||
| /// </summary> | ||
| public ConfigSettings ConfigSettings { get; set; } | ||
| } | ||
|
|
||
| internal class SystemPluginConfig { | ||
| // Название стадии по умолчанию | ||
| public string DefaultPhaseName => "Основная планировка"; | ||
|
|
||
| // Количество вариантов знаков по умолчанию | ||
| public int DefaultAccuracyRange => 3; | ||
|
|
||
| // Количество знаков по умолчанию | ||
| public int DefaultAccuracy => 1; | ||
|
|
||
| // Сторона округления | ||
| public MidpointRounding MidpointRounding => MidpointRounding.AwayFromZero; | ||
|
|
||
| // Системный параметр площади помещений по умолчанию | ||
| public BuiltInParameter SystemRoomAreaParamId => BuiltInParameter.ROOM_AREA; | ||
|
|
||
| // Общий параметр площади помещений по умолчанию | ||
| public RevitParam RoomAreaParam => SharedParamsConfig.Instance.RoomArea; | ||
| } |
16 changes: 16 additions & 0 deletions
16
src/RevitRoundingOfAreas/Models/Providers/ElementsProviderAll.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| using System.Collections.Generic; | ||
|
|
||
| using Autodesk.Revit.DB; | ||
|
|
||
| using RevitRoundingOfAreas.Models.Enums; | ||
| using RevitRoundingOfAreas.Models.Interfaces; | ||
|
|
||
| namespace RevitRoundingOfAreas.Models.Providers; | ||
|
|
||
| internal class ElementsProviderAll(RevitRepository revitRepository) : IElementsProvider { | ||
| public ElementsProviderType Type => ElementsProviderType.AllElementsProvider; | ||
|
|
||
| public List<SpatialModel> GetSpatialElements(ElementId phaseId) { | ||
| return revitRepository.GetAllSpatialModels(phaseId); | ||
| } | ||
| } |
16 changes: 16 additions & 0 deletions
16
src/RevitRoundingOfAreas/Models/Providers/ElementsProviderCurrentView.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| using System.Collections.Generic; | ||
|
|
||
| using Autodesk.Revit.DB; | ||
|
|
||
| using RevitRoundingOfAreas.Models.Enums; | ||
| using RevitRoundingOfAreas.Models.Interfaces; | ||
|
|
||
| namespace RevitRoundingOfAreas.Models.Providers; | ||
|
|
||
| internal class ElementsProviderCurrentView(RevitRepository revitRepository) : IElementsProvider { | ||
| public ElementsProviderType Type => ElementsProviderType.CurrentViewProvider; | ||
|
|
||
| public List<SpatialModel> GetSpatialElements(ElementId phaseId) { | ||
| return revitRepository.GetActiveViewSpatialModels(phaseId); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.