Skip to content
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

RevitKrChecker: Добавлен плагин "Проверить модель" #154

Merged
merged 30 commits into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
eb39b01
Создан новый плагин RevitKrChecker
DivinN Nov 6, 2024
38bd254
Удалены ссылки на Devexpress
DivinN Nov 7, 2024
383cc4e
Произведено описание основных классов плагина
DivinN Dec 18, 2024
5d9f886
Реализована группировка в отчете
DivinN Dec 18, 2024
eeaf9c2
Реализован базовый функционал проверок
DivinN Jan 14, 2025
75d8bad
Промежуточный
DivinN Jan 16, 2025
39c7055
Промежуточная
DivinN Jan 17, 2025
aead3ef
Изменено отображение проверок в списке
DivinN Jan 20, 2025
89626f4
Реализована проверка сравнением двух параметров
DivinN Jan 21, 2025
2e4d32d
Добавлены классы опций для передачи настроек в проверки. Добавлены не…
DivinN Jan 21, 2025
aeea9ac
Изменен метод получения значения цифрового параметра. Добавлены не ос…
DivinN Jan 21, 2025
35cbb27
Изменены проверки для учета null-значений
DivinN Jan 22, 2025
c501384
Изменены классы проверок, выполнено разделение логики работы с провер…
DivinN Jan 22, 2025
0ab0671
Добавлена возможность проверки с соответствием через словарь по прави…
DivinN Jan 23, 2025
3571129
Функционал по группировке списка ошибок перенесен в VM
DivinN Jan 23, 2025
2976e1f
Реализовано сохранение значений группировки ошибок
DivinN Jan 27, 2025
68046cf
Реализована локализация основного окна
DivinN Jan 27, 2025
1287973
В сервис вынесены методы по работе со значениями словаря
DivinN Jan 28, 2025
ee29bb1
Функционал группировки списка ошибок выделен в отдельный сервис
DivinN Jan 29, 2025
d2b8367
Создание окна отчета было выполнено через Ninject
DivinN Jan 29, 2025
103c3af
Реализована локализация элементов окна отчета об ошибках
DivinN Jan 30, 2025
42acd8c
Реализована локализация объяснения отчетов об ошибках
DivinN Jan 30, 2025
08bcb31
Изменено название метода вызова окна отчета
DivinN Jan 30, 2025
2170896
Изменен метод передачи модели окна отчета и вызова окна отчета
DivinN Jan 30, 2025
252b215
Добавлена локализация отчета об ошибках на английском языке
DivinN Jan 30, 2025
1ccd4a3
Реализована локализация для текста исключений
DivinN Feb 4, 2025
9625a01
Изменена логика сбора отчета ошибки
DivinN Feb 4, 2025
5387f32
Выполнено форматирование кода
DivinN Feb 11, 2025
a3cb417
Слияние
DivinN Feb 11, 2025
b88d369
Исправлено локализация для текста исключения
DivinN Feb 18, 2025
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
37 changes: 37 additions & 0 deletions .github/workflows/publish.RevitKrChecker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: publish RevitKrChecker

on:
workflow_dispatch:
pull_request:
types: [ closed, synchronize, review_requested ]
branches: [ main, master ]
paths:
- '**RevitKrChecker**.cs'
- '**RevitKrChecker**.xaml'

env:
plugin-name: "RevitKrChecker"

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 }}
15 changes: 15 additions & 0 deletions .nuke/parameters.RevitKrChecker.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"$schema": "./build.schema.json",
"Solution": "RevitPlugins.sln",
"PluginName": "RevitKrChecker",
"PublishDirectory": "03.KR.extension\\КР.tab\\bin",
"RevitVersions": [
"Rv2022",
"Rv2023",
"Rv2024"
],
"IconUrl": "https://icons8.com/icon/LunGMFAtVtVk/financial-growth-analysis",
"BundleName": "Проверить модель",
"BundleType": "InvokeButton",
"BundleOutput": "03.KR.extension\\КР.tab\\ВОР.panel"
}
16 changes: 16 additions & 0 deletions RevitPlugins.sln
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RevitRoomExtrusion", "src\R
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RevitCopyInteriorSpecs", "src\RevitCopyInteriorSpecs\RevitCopyInteriorSpecs.csproj", "{43E15E52-D6E1-434B-892B-DA63865E6B45}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RevitKrChecker", "src\RevitKrChecker\RevitKrChecker.csproj", "{54B921FA-A2E3-41E4-94B9-8BE7D2F4AE3F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
D2020|x64 = D2020|x64
Expand Down Expand Up @@ -982,6 +984,20 @@ Global
{43E15E52-D6E1-434B-892B-DA63865E6B45}.Debug|x64.Build.0 = D2020|x64
{43E15E52-D6E1-434B-892B-DA63865E6B45}.Release|x64.ActiveCfg = D2020|x64
{43E15E52-D6E1-434B-892B-DA63865E6B45}.Release|x64.Build.0 = D2020|x64
{54B921FA-A2E3-41E4-94B9-8BE7D2F4AE3F}.D2020|x64.ActiveCfg = D2020|x64
{54B921FA-A2E3-41E4-94B9-8BE7D2F4AE3F}.D2020|x64.Build.0 = D2020|x64
{54B921FA-A2E3-41E4-94B9-8BE7D2F4AE3F}.D2021|x64.ActiveCfg = D2021|x64
{54B921FA-A2E3-41E4-94B9-8BE7D2F4AE3F}.D2021|x64.Build.0 = D2021|x64
{54B921FA-A2E3-41E4-94B9-8BE7D2F4AE3F}.D2022|x64.ActiveCfg = D2022|x64
{54B921FA-A2E3-41E4-94B9-8BE7D2F4AE3F}.D2022|x64.Build.0 = D2022|x64
{54B921FA-A2E3-41E4-94B9-8BE7D2F4AE3F}.D2023|x64.ActiveCfg = D2023|x64
{54B921FA-A2E3-41E4-94B9-8BE7D2F4AE3F}.D2023|x64.Build.0 = D2023|x64
{54B921FA-A2E3-41E4-94B9-8BE7D2F4AE3F}.D2024|x64.ActiveCfg = D2024|x64
{54B921FA-A2E3-41E4-94B9-8BE7D2F4AE3F}.D2024|x64.Build.0 = D2024|x64
{54B921FA-A2E3-41E4-94B9-8BE7D2F4AE3F}.Debug|x64.ActiveCfg = D2020|x64
{54B921FA-A2E3-41E4-94B9-8BE7D2F4AE3F}.Debug|x64.Build.0 = D2020|x64
{54B921FA-A2E3-41E4-94B9-8BE7D2F4AE3F}.Release|x64.ActiveCfg = D2020|x64
{54B921FA-A2E3-41E4-94B9-8BE7D2F4AE3F}.Release|x64.Build.0 = D2020|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
40 changes: 40 additions & 0 deletions src/RevitKrChecker/Localization/Language.en-US.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">

<system:String x:Key="MainWindow.Title">Check model</system:String>
<system:String x:Key="MainWindow.GetFromView">Get elements from view</system:String>
<system:String x:Key="MainWindow.GetFromProject">Get items from the entire project</system:String>

<system:String x:Key="ReportWindow.Grouping">Grouping:</system:String>
<system:String x:Key="ReportWindow.Expand">Expand</system:String>
<system:String x:Key="ReportWindow.Collapse">Collapse</system:String>
<system:String x:Key="ReportWindow.ErrorExplanations">Error explanations:</system:String>
<system:String x:Key="ReportWindow.Show">Show</system:String>
<system:String x:Key="ReportWindow.Recheck">Recheck</system:String>

<system:String x:Key="ReportWindow.ElementCategoryName">Category name</system:String>
<system:String x:Key="ReportWindow.ElementTypeName">Type name</system:String>
<system:String x:Key="ReportWindow.Elem">Element</system:String>
<system:String x:Key="ReportWindow.TargetParamName">Parameter to check</system:String>
<system:String x:Key="ReportWindow.СheckName">Check name</system:String>
<system:String x:Key="ReportWindow.ElementErrorTooltip">Error explanation</system:String>

<system:String x:Key="ReportWindow.ParameterValue">parameter value</system:String>
<system:String x:Key="ReportWindow.Missing">missing</system:String>
<system:String x:Key="ReportWindow.ByRule">by rule</system:String>

<system:String x:Key="ReportWindow.Equals">Equals</system:String>
<system:String x:Key="ReportWindow.NotEquals">not equals</system:String>
<system:String x:Key="ReportWindow.Contains">Contains</system:String>
<system:String x:Key="ReportWindow.NotContains">not contains</system:String>
<system:String x:Key="ReportWindow.StartsWith">Starts with</system:String>
<system:String x:Key="ReportWindow.NotStartsWith">not starts with</system:String>

<system:String x:Key="ReportWindow.CheckNotForMaterialParameter">The check is not provided for checking the material parameter</system:String>
<system:String x:Key="ReportWindow.CheckNotForElementParameter">The check is not provided for checking the instance or type parameter</system:String>
<system:String x:Key="ReportWindow.CheckNotForCompareWithElementParameter">The check is not intended for comparison with instance or type parameters</system:String>
<system:String x:Key="ReportWindow.CheckNotForCompareWithMaterialParameter">The check is not intended for comparison with material parameters</system:String>

<system:String x:Key="ReportWindow.SetUnknownParameterLevel">Unknown parameter level specified</system:String>
</ResourceDictionary>
40 changes: 40 additions & 0 deletions src/RevitKrChecker/Localization/Language.ru-RU.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">

<system:String x:Key="MainWindow.Title">Проверить модель</system:String>
<system:String x:Key="MainWindow.GetFromView">Получить элементы с вида</system:String>
<system:String x:Key="MainWindow.GetFromProject">Получить элементы со всего проекта</system:String>

<system:String x:Key="ReportWindow.Grouping">Группировка:</system:String>
<system:String x:Key="ReportWindow.Expand">Развернуть</system:String>
<system:String x:Key="ReportWindow.Collapse">Свернуть</system:String>
<system:String x:Key="ReportWindow.ErrorExplanations">Объяснения ошибок:</system:String>
<system:String x:Key="ReportWindow.Show">Показать</system:String>
<system:String x:Key="ReportWindow.ReCheck">Перепроверить</system:String>

<system:String x:Key="ReportWindow.ElementCategoryName">Имя категории</system:String>
<system:String x:Key="ReportWindow.ElementTypeName">Имя типа</system:String>
<system:String x:Key="ReportWindow.Elem">Элемент</system:String>
<system:String x:Key="ReportWindow.TargetParamName">Проверяемый параметр</system:String>
<system:String x:Key="ReportWindow.СheckName">Имя проверки</system:String>
<system:String x:Key="ReportWindow.ElementErrorTooltip">Объяснение ошибки</system:String>

<system:String x:Key="ReportWindow.ParameterValue">значение параметра</system:String>
<system:String x:Key="ReportWindow.Missing">отсутствует</system:String>
<system:String x:Key="ReportWindow.ByRule">по правилу</system:String>

<system:String x:Key="ReportWindow.Equals">Равно</system:String>
<system:String x:Key="ReportWindow.NotEquals">не равно</system:String>
<system:String x:Key="ReportWindow.Contains">Содержит</system:String>
<system:String x:Key="ReportWindow.NotContains">не содержит</system:String>
<system:String x:Key="ReportWindow.StartsWith">Начинается с</system:String>
<system:String x:Key="ReportWindow.NotStartsWith">не начинается с</system:String>

<system:String x:Key="ReportWindow.CheckNotForMaterialParameter">Проверка не предусмотрена для проверки параметра материала</system:String>
<system:String x:Key="ReportWindow.CheckNotForElementParameter">Проверка не предусмотрена для проверки параметра экземпляра или типоразмера</system:String>
<system:String x:Key="ReportWindow.CheckNotForCompareWithElementParameter">Проверка не предусмотрена для сравнения c параметрами экземпляра или типоразмера</system:String>
<system:String x:Key="ReportWindow.CheckNotForCompareWithMaterialParameter">Проверка не предусмотрена для сравнения c параметрами материала</system:String>

<system:String x:Key="ReportWindow.SetUnknownParameterLevel">Задан неизвестный уровень параметра</system:String>
</ResourceDictionary>
83 changes: 83 additions & 0 deletions src/RevitKrChecker/Models/Check/CompareElemParamsCheck.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
using System;
using System.Collections.Generic;
using System.Linq;

using Autodesk.Revit.DB;

using dosymep.SimpleServices;

using RevitKrChecker.Models.CheckOptions;
using RevitKrChecker.Models.Interfaces;
using RevitKrChecker.Models.Services;

namespace RevitKrChecker.Models.Check {
public class CompareElemParamsCheck : ICheck {
private readonly ILocalizationService _localizationService;
private readonly ParamValueService _paramService;

public CompareElemParamsCheck(
CompareCheckOptions checkOptions,
ILocalizationService localizationService,
ParamValueService paramValueService) {

_localizationService = localizationService;
_paramService = paramValueService;

CheckName = checkOptions.CheckName
?? throw new ArgumentNullException(nameof(checkOptions.CheckName));

TargetParamName = checkOptions.TargetParamName
?? throw new ArgumentNullException(nameof(checkOptions.TargetParamName));
TargetParamLevel = checkOptions.TargetParamLevel is ParamLevel.Material
? throw new ArgumentException(
_localizationService.GetLocalizedString("ReportWindow.CheckNotForMaterialParameter"))
: checkOptions.TargetParamLevel;

CheckRule = checkOptions.CheckRule
?? throw new ArgumentNullException(nameof(checkOptions.CheckRule));

SourceParamName = checkOptions.SourceParamName
?? throw new ArgumentNullException(nameof(checkOptions.SourceParamName));
SourceParamLevel = checkOptions.SourceParamLevel;
}


public string CheckName { get; }
public string TargetParamName { get; }
public ParamLevel TargetParamLevel { get; }
public ICheckRule CheckRule { get; }
private string SourceParamName { get; }
public ParamLevel SourceParamLevel { get; }

private bool CheckAllValues(string targetParamValue, List<string> sourceParamValues) {
return sourceParamValues.All(sourceParamValue =>
CheckRule.Check(targetParamValue, sourceParamValue));
}

public bool Check(Element element, out CheckInfo info) {
if(element == null) {
throw new ArgumentNullException(nameof(element));
}

string targetParamValue = _paramService.GetParamValueToCheck(element, TargetParamName, TargetParamLevel);
List<string> sourceParamValues =
_paramService.GetParamValuesToCheck(element, SourceParamName, SourceParamLevel);

// Значение проверяемого параметра должно соответствовать каждому из значений (может быть несколько,
// если материалов несколько)
if(!CheckAllValues(targetParamValue, sourceParamValues)) {
info = new CheckInfo(CheckName, TargetParamName, element, GetTooltip());
return false;
}
info = null;
return true;
}

public string GetTooltip() {
// "значение параметра"
var parameterValue = _localizationService.GetLocalizedString("ReportWindow.ParameterValue");
return $"{CheckName}: {parameterValue} \"{TargetParamName}\" " +
$"{CheckRule.UnfulfilledRule} \"{SourceParamName}\"";
}
}
}
87 changes: 87 additions & 0 deletions src/RevitKrChecker/Models/Check/CompareMaterialElemParamsCheck.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
using System;
using System.Collections.Generic;
using System.Linq;

using Autodesk.Revit.DB;

using dosymep.Revit;
using dosymep.SimpleServices;

using RevitKrChecker.Models.CheckOptions;
using RevitKrChecker.Models.Interfaces;
using RevitKrChecker.Models.Services;

namespace RevitKrChecker.Models.Check {
public class CompareMaterialElemParamsCheck : ICheck {
private readonly ILocalizationService _localizationService;
private readonly ParamValueService _paramService;

public CompareMaterialElemParamsCheck(
CompareCheckOptions checkOptions,
ILocalizationService localizationService,
ParamValueService paramValueService) {

_localizationService = localizationService;
_paramService = paramValueService;

CheckName = checkOptions.CheckName
?? throw new ArgumentNullException(nameof(checkOptions.CheckName));

TargetParamName = checkOptions.TargetParamName
?? throw new ArgumentNullException(nameof(checkOptions.TargetParamName));
// Проверяем, что параметр для проверки на уровне материала
TargetParamLevel = checkOptions.TargetParamLevel != ParamLevel.Material
? throw new ArgumentException(
_localizationService.GetLocalizedString("ReportWindow.CheckNotForElementParameter"))
: checkOptions.TargetParamLevel;

CheckRule = checkOptions.CheckRule
?? throw new ArgumentNullException(nameof(checkOptions.CheckRule));

SourceParamName = checkOptions.SourceParamName
?? throw new ArgumentNullException(nameof(checkOptions.SourceParamName));
SourceParamLevel = checkOptions.SourceParamLevel is ParamLevel.Material
? throw new ArgumentException(
_localizationService.GetLocalizedString("ReportWindow.CheckNotForCompareWithMaterialParameter"))
: checkOptions.SourceParamLevel;
}


public string CheckName { get; }
public string TargetParamName { get; }
public ParamLevel TargetParamLevel { get; }
public ICheckRule CheckRule { get; }
private string SourceParamName { get; }
public ParamLevel SourceParamLevel { get; }


public bool Check(Element element, out CheckInfo info) {
if(element == null) {
throw new ArgumentNullException(nameof(element));
}

Document doc = element.Document;
List<Element> materials = element.GetMaterialIds(false)
.Select(id => doc.GetElement(id))
.ToList();
string sourceParamValue = _paramService.GetParamValueToCheck(element, SourceParamName, SourceParamLevel);

foreach(Element material in materials) {
string targetParamValue = material.GetParam(TargetParamName).AsValueString();
if(!CheckRule.Check(targetParamValue, sourceParamValue)) {
info = new CheckInfo(CheckName, TargetParamName, element, GetTooltip());
return false;
}
}
info = null;
return true;
}

public string GetTooltip() {
// "значение параметра"
var parameterValue = _localizationService.GetLocalizedString("ReportWindow.ParameterValue");
return $"{CheckName}: {parameterValue} \"{TargetParamName}\" " +
$"{CheckRule.UnfulfilledRule} \"{SourceParamName}\"";
}
}
}
Loading