Skip to content

Commit 1f3f89e

Browse files
authored
RevitPackageDocumentation: Добавлен плагин "Документация комплекта" (#473)
1 parent 98eb157 commit 1f3f89e

72 files changed

Lines changed: 9074 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: publish RevitPackageDocumentation
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
types: [ closed, synchronize, review_requested ]
7+
branches: [ main, master ]
8+
paths:
9+
- '**RevitPackageDocumentation**.cs'
10+
- '**RevitPackageDocumentation**.xaml'
11+
12+
env:
13+
plugin-name: "RevitPackageDocumentation"
14+
15+
jobs:
16+
build:
17+
name: build
18+
runs-on: windows-latest
19+
steps:
20+
- uses: actions/checkout@v3
21+
with:
22+
fetch-depth: 0
23+
24+
# Install the .NET workload
25+
- name: Install .NET
26+
uses: actions/setup-dotnet@v4
27+
with:
28+
dotnet-version: 8.0.x
29+
30+
- name: Run './build.cmd '
31+
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 }}
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"$schema": "./build.schema.json",
3+
"Solution": "RevitPlugins.slnx",
4+
"PluginName": "RevitPackageDocumentation",
5+
"PublishDirectory": "03.KR.extension\\КР.tab\\bin",
6+
"RevitVersions": [
7+
"Rv2022",
8+
"Rv2023",
9+
"Rv2024"
10+
],
11+
"IconUrl": "https://icons8.com/icon/RmqYpunlNguf/selective-highlighting",
12+
"BundleName": "Документация комплекта",
13+
"BundleType": "InvokeButton",
14+
"BundleOutput": "03.KR.extension\\КР.tab\\Документация.panel"
15+
}

RevitPlugins.slnx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@
155155
<Project Path="src/RevitOverridingGraphicsInViews/RevitOverridingGraphicsInViews.csproj">
156156
<Platform Project="x64" />
157157
</Project>
158+
<Project Path="src/RevitPackageDocumentation/RevitPackageDocumentation.csproj">
159+
<Platform Project="x64" />
160+
</Project>
158161
<Project Path="src/RevitParamsChecker/RevitParamsChecker.csproj">
159162
<Platform Project="x64" />
160163
</Project>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System;
2+
3+
namespace RevitPackageDocumentation.Models;
4+
public class ComponentTypeItem {
5+
public Type ComponentType { get; set; }
6+
public string DisplayName { get; set; }
7+
8+
public ComponentTypeItem(Type type, string displayName) {
9+
ComponentType = type;
10+
DisplayName = displayName;
11+
}
12+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
using System;
2+
3+
using dosymep.SimpleServices;
4+
5+
using pyRevitLabs.Json;
6+
using pyRevitLabs.Json.Linq;
7+
8+
namespace RevitPackageDocumentation.Models.ConfigSerializer;
9+
10+
/// <summary>
11+
/// Конвертер для полиморфной десериализации параметров плагина
12+
/// </summary>
13+
public class PluginParamConverter : JsonConverter {
14+
private readonly ILocalizationService _localizationService;
15+
16+
private const string _pluginParamTypeProperty = "PluginParamType";
17+
private const string _stringParamType = "StringParam";
18+
private const string _selectElemParamType = "SelectElem";
19+
20+
public PluginParamConverter(ILocalizationService localizationService) {
21+
_localizationService = localizationService;
22+
}
23+
24+
public override bool CanConvert(Type objectType) {
25+
return objectType == typeof(PluginParamData);
26+
}
27+
28+
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) {
29+
var jObject = JObject.Load(reader);
30+
var paramType = jObject[_pluginParamTypeProperty]?.Value<string>();
31+
32+
if(string.IsNullOrEmpty(paramType))
33+
throw new JsonSerializationException(
34+
$"{_localizationService.GetLocalizedString("MainViewModel.Property")} '{_pluginParamTypeProperty}' " +
35+
$"{_localizationService.GetLocalizedString("MainViewModel.NotFoundInJSON")}");
36+
37+
try {
38+
return paramType switch {
39+
_stringParamType => jObject.ToObject<StringParamData>(serializer),
40+
_selectElemParamType => jObject.ToObject<SelectElemParamData>(serializer),
41+
_ => throw new NotSupportedException(
42+
$"{_localizationService.GetLocalizedString("MainViewModel.UnknownPluginParamType")}: {paramType}")
43+
};
44+
} catch(Exception ex) {
45+
throw new JsonSerializationException(
46+
$"{_localizationService.GetLocalizedString("MainViewModel.ErrorDeserializingType")} '{paramType}'", ex);
47+
}
48+
}
49+
50+
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) {
51+
serializer.Serialize(writer, value);
52+
}
53+
54+
public override bool CanWrite => true;
55+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
using System;
2+
3+
using dosymep.SimpleServices;
4+
5+
using pyRevitLabs.Json;
6+
using pyRevitLabs.Json.Linq;
7+
8+
namespace RevitPackageDocumentation.Models.ConfigSerializer;
9+
10+
/// <summary>
11+
/// Конвертер для полиморфной десериализации компонентов листа
12+
/// </summary>
13+
public class SheetComponentConverter : JsonConverter {
14+
private readonly ILocalizationService _localizationService;
15+
16+
private const string _componentTypeProperty = "ComponentType";
17+
private const string _structuralPlanViewType = "PlanView";
18+
private const string _structuralCalloutViewType = "CalloutView";
19+
private const string _sectionViewType = "SectionView";
20+
private const string _scheduleViewType = "ScheduleView";
21+
private const string _textNoteType = "TextNote";
22+
private const string _typicalAnnotationType = "TypicalAnnotation";
23+
private const string _legendViewType = "LegendView";
24+
25+
public SheetComponentConverter(ILocalizationService localizationService) {
26+
_localizationService = localizationService;
27+
}
28+
29+
public override bool CanConvert(Type objectType) {
30+
return objectType == typeof(SheetComponentData);
31+
}
32+
33+
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) {
34+
var jObject = JObject.Load(reader);
35+
var componentType = jObject[_componentTypeProperty]?.Value<string>();
36+
37+
if(string.IsNullOrEmpty(componentType))
38+
throw new JsonSerializationException(
39+
$"{_localizationService.GetLocalizedString("MainViewModel.Property")} '{_componentTypeProperty}' " +
40+
$"{_localizationService.GetLocalizedString("MainViewModel.NotFoundInJSON")}");
41+
42+
try {
43+
return componentType switch {
44+
_structuralPlanViewType => jObject.ToObject<PlanViewData>(serializer),
45+
_structuralCalloutViewType => jObject.ToObject<CalloutViewData>(serializer),
46+
_sectionViewType => jObject.ToObject<SectionViewData>(serializer),
47+
_scheduleViewType => jObject.ToObject<ScheduleViewData>(serializer),
48+
_textNoteType => jObject.ToObject<TextNoteData>(serializer),
49+
_typicalAnnotationType => jObject.ToObject<TypicalAnnotationData>(serializer),
50+
_legendViewType => jObject.ToObject<LegendViewData>(serializer),
51+
_ => throw new NotSupportedException(
52+
$"{_localizationService.GetLocalizedString("MainViewModel.UnknownComponentType")}: {componentType}")
53+
};
54+
} catch(Exception ex) {
55+
throw new JsonSerializationException(
56+
$"{_localizationService.GetLocalizedString("MainViewModel.ErrorDeserializingType")} '{componentType}'", ex);
57+
}
58+
}
59+
60+
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) {
61+
serializer.Serialize(writer, value);
62+
}
63+
64+
public override bool CanWrite => true;
65+
}

0 commit comments

Comments
 (0)