Skip to content
Merged
Show file tree
Hide file tree
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
33 changes: 33 additions & 0 deletions .github/workflows/publish.RevitSplitMepCurve.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: publish RevitSplitMepCurve

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

env:
plugin-name: "RevitSplitMepCurve"

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

- 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.RevitSplitMepCurve.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"$schema": "./build.schema.json",
"Solution": "RevitPlugins.slnx",
"PluginName": "RevitSplitMepCurve",
"PublishDirectory": "01.BIM.extension\\BIM.tab\\bin",
"RevitVersions": [
"Rv2022",
"Rv2023",
"Rv2024"
],
"IconUrl": "https://icons8.com/icon/22945/cut-paper",
"BundleName": "Разделить по уровню СМР",
"BundleType": "InvokeButton",
"BundleOutput": "01.BIM.extension\\BIM.tab\\СМР.panel\\СМР.pulldown"
}
3 changes: 3 additions & 0 deletions RevitPlugins.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,9 @@
<Project Path="src/RevitSleeves/RevitSleeves.csproj">
<Platform Project="x64" />
</Project>
<Project Path="src/RevitSplitMepCurve/RevitSplitMepCurve.csproj">
<Platform Project="x64" />
</Project>
<Project Path="src/RevitSuperfilter/RevitSuperfilter.csproj">
<Platform Project="x64" />
</Project>
Expand Down
25 changes: 25 additions & 0 deletions src/RevitSplitMepCurve/Models/ConnectorConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;

using Autodesk.Revit.DB;

namespace RevitSplitMepCurve.Models;

internal class ConnectorConfig {
public string FamilyName { get; set; } = string.Empty;

public string SymbolName { get; set; } = string.Empty;

public bool Equals(FamilySymbol s) {
if(s is null) {
return false;
}

if(FamilyName is null
|| SymbolName is null) {
return false;
}

return SymbolName.Equals(s.Name, StringComparison.CurrentCultureIgnoreCase)
&& FamilyName.Equals(s.FamilyName, StringComparison.CurrentCultureIgnoreCase);
}
}
6 changes: 6 additions & 0 deletions src/RevitSplitMepCurve/Models/Enums/MepClass.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace RevitSplitMepCurve.Models.Enums;

internal enum MepClass {
Pipes,
Ducts
}
7 changes: 7 additions & 0 deletions src/RevitSplitMepCurve/Models/Enums/SelectionMode.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace RevitSplitMepCurve.Models.Enums;

internal enum SelectionMode {
SelectedElements,
ActiveView,
ActiveDocument
}
54 changes: 54 additions & 0 deletions src/RevitSplitMepCurve/Models/Errors/ErrorModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using System;

using Autodesk.Revit.DB;

namespace RevitSplitMepCurve.Models.Errors;

internal class ErrorModel : IEquatable<ErrorModel> {
private readonly ElementId _id;

public ErrorModel(Element element, string message) {
if(string.IsNullOrWhiteSpace(message)) {
throw new ArgumentException(nameof(message));
}
Message = message;
Element = element ?? throw new ArgumentNullException(nameof(element));
_id = Element.Id;
}

public string Message { get; }

public Element Element { get; }

public bool Equals(ErrorModel other) {
if(other is null) {
return false;
}

if(ReferenceEquals(this, other)) {
return true;
}

return Equals(_id, other._id);
}

public override bool Equals(object obj) {
if(obj is null) {
return false;
}

if(ReferenceEquals(this, obj)) {
return true;
}

if(obj.GetType() != GetType()) {
return false;
}

return Equals((ErrorModel) obj);
}

public override int GetHashCode() {
return _id.GetHashCode();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;

namespace RevitSplitMepCurve.Models.Exceptions;

/// <summary>
/// Исключение, когда не удалось создать коннектор
/// </summary>
internal class CannotCreateConnectorException : Exception {
public CannotCreateConnectorException()
: base() {
}

public CannotCreateConnectorException(string msg)
: base(msg) {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;

namespace RevitSplitMepCurve.Models.Exceptions;

/// <summary>
/// Исключение, когда не удалось получить типоразмер соединителя для вставки
/// </summary>
internal class CannotGetConnectorSymbolException : Exception {
public CannotGetConnectorSymbolException()
: base() {
}

public CannotGetConnectorSymbolException(string msg)
: base(msg) {
}
}
47 changes: 47 additions & 0 deletions src/RevitSplitMepCurve/Models/PluginConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using System.Collections.Generic;

using dosymep.Bim4Everyone;
using dosymep.Bim4Everyone.ProjectConfigs;

using pyRevitLabs.Json;

using RevitSplitMepCurve.Models.Enums;

namespace RevitSplitMepCurve.Models;

internal class PluginConfig : ProjectConfig<RevitSettings> {
[JsonIgnore]
public override string ProjectConfigPath { get; set; }

[JsonIgnore]
public override IConfigSerializer Serializer { get; set; }

public static PluginConfig GetPluginConfig(IConfigSerializer configSerializer) {
return new ProjectConfigBuilder()
.SetSerializer(configSerializer)
.SetPluginName(nameof(RevitSplitMepCurve))
.SetRevitVersion(ModuleEnvironment.RevitVersion)
.SetProjectConfigName(nameof(PluginConfig) + ".json")
.Build<PluginConfig>();
}
}

internal class RevitSettings : ProjectSettings {
public const MepClass DefaultMepClass = MepClass.Pipes;
public const SelectionMode DefaultSelectionMode = SelectionMode.ActiveView;

public override string ProjectName { get; set; }

public MepClass SelectedMepClass { get; set; } = DefaultMepClass;

public SelectionMode SelectedMode { get; set; } = DefaultSelectionMode;

public ConnectorConfig RoundConnector { get; set; } = new ConnectorConfig();

public ConnectorConfig RectangleConnector { get; set; } = new ConnectorConfig();

/// <summary>Имена уровней, исключённых пользователем.</summary>
public List<string> UncheckedLevelNames { get; set; } = [];

public bool ShowSplitErrors { get; set; } = true;
}
Loading
Loading