diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8c423742..211cfdbf 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,9 +2,9 @@ name: Build (Windows) - SAM_Revit (2025/2026) on: push: - branches: [ "master", "main" ] + branches: [ "master", "main", "sow/**" ] pull_request: - branches: [ "master", "main" ] + branches: [ "master", "main", "sow/**" ] workflow_dispatch: jobs: @@ -39,6 +39,36 @@ jobs: uses: nuget/setup-nuget@v2 with: nuget-version: "6.x" + - name: Compute SAMVersion + id: ver + shell: pwsh + run: | + $ErrorActionPreference = 'Stop' + # Prefer head_ref when its a sow branch (release-promotion PRs from sow/* to main), + # else use base_ref on PR events / ref_name on push events. + $headRef = '${{ github.head_ref }}' + $baseRef = '${{ github.base_ref }}' + $refName = '${{ github.ref_name }}' + if ($headRef -match '^sow/\d{4}-Q\d$') { + $ref = $headRef + } elseif ('${{ github.event_name }}' -eq 'pull_request') { + $ref = $baseRef + } else { + $ref = $refName + } + # .NET AssemblyVersion components are UInt16 (max 65535). Cap to 60000 for headroom. + $run = ${{ github.run_number }} % 60000 + if ($ref -match 'sow/(\d{4})-Q(\d)') { + $v = "$($Matches[1]).$($Matches[2]).$run.0" + $src = "branch '$ref'" + } else { + $now = (Get-Date).ToUniversalTime() + $quarter = [int][Math]::Ceiling($now.Month / 3.0) + $v = "$($now.Year).$quarter.$run.0" + $src = "date $($now.ToString('yyyy-MM-dd')) (ref '$ref' not sow/yyyy-Qx)" + } + Write-Host "SAMVersion = $v (from $src)" + "samversion=$v" | Out-File -FilePath $env:GITHUB_OUTPUT -Append -Encoding utf8 - name: Clone dependency repos (siblings) + build order shell: powershell @@ -85,7 +115,37 @@ jobs: 'SAM_Revit_UI' ) - foreach ($r in $deps) { Clone-Repo $r } + foreach ($r in $deps) { + if (Test-Path $r) { continue } + $headRef = '${{ github.head_ref }}' + $baseRef = '${{ github.base_ref }}' + $refName = '${{ github.ref_name }}' + $candidates = @() + if ($headRef) { $candidates += $headRef } + # Current sow branch: base_ref on PR events, ref_name on push events. + $sowRef = if ($baseRef -match '^sow/') { $baseRef } elseif ($refName -match '^sow/') { $refName } else { '' } + if ($sowRef -and $sowRef -ne $headRef) { $candidates += $sowRef } + $candidates += 'sow/2026-Q2' + # Use the auth-token form so private deps (e.g. SAM_Solver) don't prompt + $url = if ($token) { "https://$token@github.com/$org/$r.git" } else { "https://github.com/$org/$r.git" } + $cloned = $false + foreach ($cand in $candidates) { + $has = (git ls-remote --heads $url $cand 2>$null | Out-String).Trim() + if ($has) { + Write-Host "Cloning $org/$r @ $cand" + git clone --depth 1 --branch $cand $url $r + if ($LASTEXITCODE -ne 0) { throw "Failed to clone $r @ $cand" } + $cloned = $true + break + } + } + if (-not $cloned) { + Write-Host "Cloning $org/$r @ default branch" + git clone --depth 1 $url $r + if ($LASTEXITCODE -ne 0) { throw "Failed to clone $r" } + } + } + # Ensure build folders exist (some projects expect these paths) New-Item -ItemType Directory -Force -Path "SAM_Windows\build" | Out-Null @@ -147,6 +207,7 @@ jobs: '/nr:false' '/v:m' '/p:UseSharedCompilation=false' + '/p:SAMVersion=${{ steps.ver.outputs.samversion }}' '/p:RunPostBuildEvent=OnOutputUpdated' ) @@ -220,6 +281,7 @@ jobs: '/nr:false' '/v:m' '/p:UseSharedCompilation=false' + '/p:SAMVersion=${{ steps.ver.outputs.samversion }}' '/p:RunPostBuildEvent=OnOutputUpdated' "/p:Configuration=$cfg" '/p:Platform=Any CPU' @@ -307,6 +369,7 @@ jobs: '/nr:false' '/v:m' '/p:UseSharedCompilation=false' + '/p:SAMVersion=${{ steps.ver.outputs.samversion }}' '/p:RunPostBuildEvent=OnOutputUpdated' "/p:Configuration=$cfg" '/p:Platform=Any CPU' diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 00000000..509f4c68 --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,57 @@ + + + + + 1.0.0.0 + $(SAMVersion) + $(SAMVersion) + + $(SAMVersion)+$(SAMSourceRevision) + + false + true + + + + + + <_SAMVersionLine Include="// <auto-generated />" /> + <_SAMVersionLine Include="[assembly: System.Reflection.AssemblyVersionAttribute("$(SAMVersion)")]" /> + <_SAMVersionLine Include="[assembly: System.Reflection.AssemblyFileVersionAttribute("$(SAMVersion)")]" /> + + <_SAMVersionLine Include="[assembly: System.Reflection.AssemblyInformationalVersionAttribute("$(InformationalVersion)")]" Condition="'$(InformationalVersion)' != ''" /> + + + + + + + + + + diff --git a/Grasshopper/SAM.Analytical.Grasshopper.Revit/Kernel/AssemblyInfo.cs b/Grasshopper/SAM.Analytical.Grasshopper.Revit/Kernel/AssemblyInfo.cs index acf9aa5e..66e0cf38 100644 --- a/Grasshopper/SAM.Analytical.Grasshopper.Revit/Kernel/AssemblyInfo.cs +++ b/Grasshopper/SAM.Analytical.Grasshopper.Revit/Kernel/AssemblyInfo.cs @@ -1,4 +1,7 @@ -using Grasshopper.Kernel; +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors + +using Grasshopper.Kernel; using System; using System.Drawing; diff --git a/Grasshopper/SAM.Analytical.Grasshopper.Revit/Properties/AssemblyInfo.cs b/Grasshopper/SAM.Analytical.Grasshopper.Revit/Properties/AssemblyInfo.cs index 29e70790..fc48ccae 100644 --- a/Grasshopper/SAM.Analytical.Grasshopper.Revit/Properties/AssemblyInfo.cs +++ b/Grasshopper/SAM.Analytical.Grasshopper.Revit/Properties/AssemblyInfo.cs @@ -1,4 +1,6 @@ -/* +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020-2026 Michal Dengusiak & Jakub Ziolkowski and contributors +/* * This file is part of the Sustaiable Analytical Model (SAM) * Copyright (c) 2020, the respective contributors. All rights reserved. * @@ -52,6 +54,3 @@ // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyFileVersion("1.0.*")] diff --git a/Grasshopper/SAM.Analytical.Grasshopper.Revit/SAM.Analytical.Grasshopper.Revit.csproj b/Grasshopper/SAM.Analytical.Grasshopper.Revit/SAM.Analytical.Grasshopper.Revit.csproj index 94957c0f..bd055f6a 100644 --- a/Grasshopper/SAM.Analytical.Grasshopper.Revit/SAM.Analytical.Grasshopper.Revit.csproj +++ b/Grasshopper/SAM.Analytical.Grasshopper.Revit/SAM.Analytical.Grasshopper.Revit.csproj @@ -19,7 +19,6 @@ false true true - false false false x64 @@ -640,9 +639,8 @@ compile; build; native; contentfiles; analyzers; buildtransitive - - 13.0.3 - + + @@ -707,4 +705,4 @@ - \ No newline at end of file + diff --git a/Grasshopper/SAM.Architectural.Grasshopper.Revit/Properties/AssemblyInfo.cs b/Grasshopper/SAM.Architectural.Grasshopper.Revit/Properties/AssemblyInfo.cs index 8514efea..6d510664 100644 --- a/Grasshopper/SAM.Architectural.Grasshopper.Revit/Properties/AssemblyInfo.cs +++ b/Grasshopper/SAM.Architectural.Grasshopper.Revit/Properties/AssemblyInfo.cs @@ -1,4 +1,6 @@ -/* +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020-2026 Michal Dengusiak & Jakub Ziolkowski and contributors +/* * This file is part of the Sustaiable Analytical Model (SAM) * Copyright (c) 2020, the respective contributors. All rights reserved. * @@ -52,6 +54,3 @@ // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyFileVersion("1.0.*")] diff --git a/Grasshopper/SAM.Architectural.Grasshopper.Revit/SAM.Architectural.Grasshopper.Revit.csproj b/Grasshopper/SAM.Architectural.Grasshopper.Revit/SAM.Architectural.Grasshopper.Revit.csproj index 3927edf1..1ca84b3c 100644 --- a/Grasshopper/SAM.Architectural.Grasshopper.Revit/SAM.Architectural.Grasshopper.Revit.csproj +++ b/Grasshopper/SAM.Architectural.Grasshopper.Revit/SAM.Architectural.Grasshopper.Revit.csproj @@ -19,7 +19,6 @@ false true true - false false false AnyCPU @@ -637,9 +636,8 @@ compile; build; native; contentfiles; analyzers; buildtransitive - - 13.0.3 - + + @@ -729,4 +727,4 @@ - \ No newline at end of file + diff --git a/Grasshopper/SAM.Core.Grasshopper.Revit/Classes/GooConvertSettings.cs b/Grasshopper/SAM.Core.Grasshopper.Revit/Classes/GooConvertSettings.cs index e78cce41..1c7712d2 100644 --- a/Grasshopper/SAM.Core.Grasshopper.Revit/Classes/GooConvertSettings.cs +++ b/Grasshopper/SAM.Core.Grasshopper.Revit/Classes/GooConvertSettings.cs @@ -1,4 +1,6 @@ -using GH_IO.Serialization; +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using GH_IO.Serialization; using Grasshopper.Kernel; using Grasshopper.Kernel.Types; using SAM.Core.Grasshopper.Revit.Properties; @@ -38,7 +40,7 @@ public override bool Write(GH_IWriter writer) if (Value == null) return false; - writer.SetString(typeof(ConvertSettings).FullName, Value.ToJObject().ToString()); + writer.SetString(typeof(ConvertSettings).FullName, Value.ToJsonObject().ToString()); return true; } diff --git a/Grasshopper/SAM.Core.Grasshopper.Revit/Properties/AssemblyInfo.cs b/Grasshopper/SAM.Core.Grasshopper.Revit/Properties/AssemblyInfo.cs index af7af0ce..84514ab8 100644 --- a/Grasshopper/SAM.Core.Grasshopper.Revit/Properties/AssemblyInfo.cs +++ b/Grasshopper/SAM.Core.Grasshopper.Revit/Properties/AssemblyInfo.cs @@ -1,4 +1,6 @@ -/* +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020-2026 Michal Dengusiak & Jakub Ziolkowski and contributors +/* * This file is part of the Sustaiable Analytical Model (SAM) * Copyright (c) 2020, the respective contributors. All rights reserved. * @@ -52,6 +54,3 @@ // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyFileVersion("1.0.*")] diff --git a/Grasshopper/SAM.Core.Grasshopper.Revit/SAM.Core.Grasshopper.Revit.csproj b/Grasshopper/SAM.Core.Grasshopper.Revit/SAM.Core.Grasshopper.Revit.csproj index cffaf499..f37a5a33 100644 --- a/Grasshopper/SAM.Core.Grasshopper.Revit/SAM.Core.Grasshopper.Revit.csproj +++ b/Grasshopper/SAM.Core.Grasshopper.Revit/SAM.Core.Grasshopper.Revit.csproj @@ -16,7 +16,6 @@ false true true - false false false AnyCPU @@ -686,9 +685,8 @@ compile; build; native; contentfiles; analyzers; buildtransitive - - 13.0.3 - + + @@ -778,4 +776,4 @@ - \ No newline at end of file + diff --git a/Grasshopper/SAM.Geometry.Grasshopper.Revit/Properties/AssemblyInfo.cs b/Grasshopper/SAM.Geometry.Grasshopper.Revit/Properties/AssemblyInfo.cs index 0ae38b4a..fd2fa741 100644 --- a/Grasshopper/SAM.Geometry.Grasshopper.Revit/Properties/AssemblyInfo.cs +++ b/Grasshopper/SAM.Geometry.Grasshopper.Revit/Properties/AssemblyInfo.cs @@ -1,4 +1,6 @@ -/* +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020-2026 Michal Dengusiak & Jakub Ziolkowski and contributors +/* * This file is part of the Sustaiable Analytical Model (SAM) * Copyright (c) 2020, the respective contributors. All rights reserved. * @@ -52,6 +54,3 @@ // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyFileVersion("1.0.*")] diff --git a/Grasshopper/SAM.Geometry.Grasshopper.Revit/SAM.Geometry.Grasshopper.Revit.csproj b/Grasshopper/SAM.Geometry.Grasshopper.Revit/SAM.Geometry.Grasshopper.Revit.csproj index 80fb3faf..72518b6e 100644 --- a/Grasshopper/SAM.Geometry.Grasshopper.Revit/SAM.Geometry.Grasshopper.Revit.csproj +++ b/Grasshopper/SAM.Geometry.Grasshopper.Revit/SAM.Geometry.Grasshopper.Revit.csproj @@ -16,7 +16,6 @@ false true true - false false false AnyCPU @@ -689,9 +688,8 @@ compile; build; native; contentfiles; analyzers; buildtransitive - - 13.0.3 - + + @@ -781,4 +779,4 @@ - \ No newline at end of file + diff --git a/Pdf/SAM.Core.Pdf.Revit/Properties/AssemblyInfo.cs b/Pdf/SAM.Core.Pdf.Revit/Properties/AssemblyInfo.cs index 12db11c2..cb59949d 100644 --- a/Pdf/SAM.Core.Pdf.Revit/Properties/AssemblyInfo.cs +++ b/Pdf/SAM.Core.Pdf.Revit/Properties/AssemblyInfo.cs @@ -1,4 +1,7 @@ -using System.Reflection; +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors + +using System.Reflection; using System.Runtime.InteropServices; [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/Pdf/SAM.Core.Pdf.Revit/SAM.Core.Pdf.Revit.csproj b/Pdf/SAM.Core.Pdf.Revit/SAM.Core.Pdf.Revit.csproj index cedbdbea..3b0993cf 100644 --- a/Pdf/SAM.Core.Pdf.Revit/SAM.Core.Pdf.Revit.csproj +++ b/Pdf/SAM.Core.Pdf.Revit/SAM.Core.Pdf.Revit.csproj @@ -13,8 +13,6 @@ SAM.Core.Pdf.Revit SAM.Core.Pdf.Revit Copyright © 2021 - 1.0.0.0 - 1.0.0.0 false false Debug;Release;Debug2020;Debug2021;Debug2022;Debug2023;Debug2024;Debug2025;Release2020;Release2021;Release2022;Release2023;Release2024;Release2025;Debug2026;Release2026 diff --git a/SAM_Revit/SAM.Analytical.Revit/Convert/ToRevit/FamilyInstance.cs b/SAM_Revit/SAM.Analytical.Revit/Convert/ToRevit/FamilyInstance.cs index f258c111..69308245 100644 --- a/SAM_Revit/SAM.Analytical.Revit/Convert/ToRevit/FamilyInstance.cs +++ b/SAM_Revit/SAM.Analytical.Revit/Convert/ToRevit/FamilyInstance.cs @@ -1,4 +1,6 @@ -using Autodesk.Revit.DB; +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using Autodesk.Revit.DB; using SAM.Geometry.Revit; using SAM.Geometry.Spatial; @@ -205,7 +207,7 @@ public static FamilyInstance ToRevit(this Aperture aperture, Document document, } Core.Revit.Modify.SetSimplified(result, simplified); - Core.Revit.Modify.SetJson(result, aperture.ToJObject()?.ToString()); + Core.Revit.Modify.SetJson(result, aperture.ToJsonObject()?.ToString()); } convertSettings?.Add(aperture.Guid, result); diff --git a/SAM_Revit/SAM.Analytical.Revit/Convert/ToRevit/HostObject.cs b/SAM_Revit/SAM.Analytical.Revit/Convert/ToRevit/HostObject.cs index bccbc5e8..351ed3e4 100644 --- a/SAM_Revit/SAM.Analytical.Revit/Convert/ToRevit/HostObject.cs +++ b/SAM_Revit/SAM.Analytical.Revit/Convert/ToRevit/HostObject.cs @@ -1,4 +1,6 @@ -using Autodesk.Revit.DB; +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using Autodesk.Revit.DB; using SAM.Geometry.Revit; using System; using System.Collections.Generic; @@ -316,7 +318,7 @@ public static HostObject ToRevit(this Panel panel, Document document, Core.Revit Core.Revit.Modify.SetValues(result, panel, builtInParameters); Core.Revit.Modify.SetValues(result, panel, ActiveSetting.Setting); - Core.Revit.Modify.SetJson(result, panel.ToJObject()?.ToString()); + Core.Revit.Modify.SetJson(result, panel.ToJsonObject()?.ToString()); } //TODO: Implement proper log //System.IO.File.AppendAllText(@"C:\Users\DengusiakM\Desktop\SAM\2020-04-16 floorbug\LOG.txt", string.Format("{0}\t{1}\t{2}\n", DateTime.Now.ToString(), panel.Guid, panel.Name)); diff --git a/SAM_Revit/SAM.Analytical.Revit/Convert/ToRevit/Space.cs b/SAM_Revit/SAM.Analytical.Revit/Convert/ToRevit/Space.cs index 72bc39ef..6505f70e 100644 --- a/SAM_Revit/SAM.Analytical.Revit/Convert/ToRevit/Space.cs +++ b/SAM_Revit/SAM.Analytical.Revit/Convert/ToRevit/Space.cs @@ -1,4 +1,6 @@ -using Autodesk.Revit.DB; +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using Autodesk.Revit.DB; using SAM.Core.Revit; using System.Collections.Generic; @@ -57,7 +59,7 @@ public static Autodesk.Revit.DB.Mechanical.Space ToRevit(this Space space, Docum Core.Revit.Modify.SetValues(result, space); Core.Revit.Modify.SetValues(result, space, ActiveSetting.Setting, parameters); - Core.Revit.Modify.SetJson(result, space.ToJObject()?.ToString()); + Core.Revit.Modify.SetJson(result, space.ToJsonObject()?.ToString()); } convertSettings?.Add(space.Guid, result); diff --git a/SAM_Revit/SAM.Analytical.Revit/Properties/AssemblyInfo.cs b/SAM_Revit/SAM.Analytical.Revit/Properties/AssemblyInfo.cs index d0620645..3a5e1e8a 100644 --- a/SAM_Revit/SAM.Analytical.Revit/Properties/AssemblyInfo.cs +++ b/SAM_Revit/SAM.Analytical.Revit/Properties/AssemblyInfo.cs @@ -1,4 +1,7 @@ -/* +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors + +/* * This file is part of the Sustaiable Analytical Model (SAM) * Copyright (c) 2020, the respective contributors. All rights reserved. * diff --git a/SAM_Revit/SAM.Analytical.Revit/SAM.Analytical.Revit.csproj b/SAM_Revit/SAM.Analytical.Revit/SAM.Analytical.Revit.csproj index a8e0d0e9..061149de 100644 --- a/SAM_Revit/SAM.Analytical.Revit/SAM.Analytical.Revit.csproj +++ b/SAM_Revit/SAM.Analytical.Revit/SAM.Analytical.Revit.csproj @@ -8,13 +8,10 @@ net8.0-windows net8.0-windows Library - false false SAM_Revit SAM_Revit - Copyright © 2020 - 1.0.%2a - 1.0.%2a + Copyright (c) 2020-2026 Michal Dengusiak & Jakub Ziolkowski and contributors false false Debug;Release;Debug2020;Debug2021;Debug2022;Debug2023;Debug2024;Release2024;Release2020;Release2021;Release2022;Release2023;Debug2025;Release2025;Debug2026;Release2026 @@ -219,6 +216,7 @@ - + + - \ No newline at end of file + diff --git a/SAM_Revit/SAM.Architectural.Revit/Convert/ToRevit/Level.cs b/SAM_Revit/SAM.Architectural.Revit/Convert/ToRevit/Level.cs index b6c21c4c..945abe50 100644 --- a/SAM_Revit/SAM.Architectural.Revit/Convert/ToRevit/Level.cs +++ b/SAM_Revit/SAM.Architectural.Revit/Convert/ToRevit/Level.cs @@ -1,4 +1,6 @@ -using Autodesk.Revit.DB; +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using Autodesk.Revit.DB; using SAM.Core.Revit; using System; using System.Collections.Generic; @@ -71,7 +73,7 @@ public static Autodesk.Revit.DB.Level ToRevit(this Level level, Document documen Core.Revit.Modify.SetValues(result, level); Core.Revit.Modify.SetValues(result, level, ActiveSetting.Setting); - Core.Revit.Modify.SetJson(result, level.ToJObject()?.ToString()); + Core.Revit.Modify.SetJson(result, level.ToJsonObject()?.ToString()); } convertSettings?.Add(level.Guid, result); diff --git a/SAM_Revit/SAM.Architectural.Revit/Properties/AssemblyInfo.cs b/SAM_Revit/SAM.Architectural.Revit/Properties/AssemblyInfo.cs index 59e398d0..272fed4a 100644 --- a/SAM_Revit/SAM.Architectural.Revit/Properties/AssemblyInfo.cs +++ b/SAM_Revit/SAM.Architectural.Revit/Properties/AssemblyInfo.cs @@ -1,4 +1,7 @@ -/* +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors + +/* * This file is part of the Sustaiable Analytical Model (SAM) * Copyright (c) 2020, the respective contributors. All rights reserved. * diff --git a/SAM_Revit/SAM.Architectural.Revit/SAM.Architectural.Revit.csproj b/SAM_Revit/SAM.Architectural.Revit/SAM.Architectural.Revit.csproj index bc0ace41..c26cae45 100644 --- a/SAM_Revit/SAM.Architectural.Revit/SAM.Architectural.Revit.csproj +++ b/SAM_Revit/SAM.Architectural.Revit/SAM.Architectural.Revit.csproj @@ -8,13 +8,10 @@ net8.0-windows net8.0-windows Library - false false SAM_Revit SAM_Revit - Copyright © 2020 - 1.0.%2a - 1.0.%2a + Copyright (c) 2020-2026 Michal Dengusiak & Jakub Ziolkowski and contributors false false Debug;Release;Debug2020;Debug2021;Debug2022;Debug2023;Debug2024;Release2020;Release2021;Release2022;Release2023;Release2024;Debug2025;Release2025;Debug2026;Release2026 @@ -150,7 +147,8 @@ - + + @@ -247,4 +245,4 @@ ..\..\..\SAM\build\SAM.Geometry.dll - \ No newline at end of file + diff --git a/SAM_Revit/SAM.Core.Revit/Classes/ConvertSettings.cs b/SAM_Revit/SAM.Core.Revit/Classes/ConvertSettings.cs index c3a11996..be6b4f22 100644 --- a/SAM_Revit/SAM.Core.Revit/Classes/ConvertSettings.cs +++ b/SAM_Revit/SAM.Core.Revit/Classes/ConvertSettings.cs @@ -1,5 +1,7 @@ -using Autodesk.Revit.DB; -using Newtonsoft.Json.Linq; +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using Autodesk.Revit.DB; +using System.Text.Json.Nodes; using System.Collections.Generic; using System.Linq; @@ -50,9 +52,9 @@ public ConvertSettings(ConvertSettings convertSettings) objects = new Dictionary>(); } - public ConvertSettings(JObject jObject) + public ConvertSettings(JsonObject jObject) { - FromJObject(jObject); + FromJsonObject(jObject); } public bool ConvertGeometry @@ -111,21 +113,21 @@ public bool AddParameter(string name, object value) return true; } - public bool FromJObject(JObject jObject) + public bool FromJsonObject(JsonObject jObject) { if (jObject == null) return false; - convertGeometry = jObject.Value("ConvertGeometry"); - convertParameters = jObject.Value("ConvertParameters"); - removeExisting = jObject.Value("RemoveExisting"); - useProjectLocation = jObject.Value("UseProjectLocation"); + convertGeometry = jObject["ConvertGeometry"]?.GetValue() ?? default(bool); + convertParameters = jObject["ConvertParameters"]?.GetValue() ?? default(bool); + removeExisting = jObject["RemoveExisting"]?.GetValue() ?? default(bool); + useProjectLocation = jObject["UseProjectLocation"]?.GetValue() ?? default(bool); return true; } - public JObject ToJObject() + public JsonObject ToJsonObject() { - JObject jObject = new JObject(); + JsonObject jObject = new JsonObject(); jObject.Add("_type", Core.Query.FullTypeName(this)); jObject.Add("ConvertGeometry", convertGeometry); jObject.Add("ConvertParameters", convertParameters); diff --git a/SAM_Revit/SAM.Core.Revit/Classes/DesignOption.cs b/SAM_Revit/SAM.Core.Revit/Classes/DesignOption.cs index cb9732d9..8d952351 100644 --- a/SAM_Revit/SAM.Core.Revit/Classes/DesignOption.cs +++ b/SAM_Revit/SAM.Core.Revit/Classes/DesignOption.cs @@ -1,5 +1,6 @@ -using Newtonsoft.Json.Linq; - +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using System.Text.Json.Nodes; namespace SAM.Core.Revit { public class DesignOption: SAMObject @@ -18,7 +19,7 @@ public DesignOption(string name, bool isPrimary) this.isPrimary = isPrimary; } - public DesignOption(JObject jObject) + public DesignOption(JsonObject jObject) : base(jObject) { @@ -32,17 +33,17 @@ public bool IsPrimary } } - public override bool FromJObject(JObject jObject) + public override bool FromJsonObject(JsonObject jObject) { - if (!base.FromJObject(jObject)) + if (!base.FromJsonObject(jObject)) return false; return true; } - public override JObject ToJObject() + public override JsonObject ToJsonObject() { - JObject jObject = base.ToJObject(); + JsonObject jObject = base.ToJsonObject(); if (jObject == null) return jObject; diff --git a/SAM_Revit/SAM.Core.Revit/Classes/ElementBindingData.cs b/SAM_Revit/SAM.Core.Revit/Classes/ElementBindingData.cs index d4ba3c1a..7365ce97 100644 --- a/SAM_Revit/SAM.Core.Revit/Classes/ElementBindingData.cs +++ b/SAM_Revit/SAM.Core.Revit/Classes/ElementBindingData.cs @@ -1,5 +1,7 @@ -using Autodesk.Revit.DB; -using Newtonsoft.Json.Linq; +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using Autodesk.Revit.DB; +using System.Text.Json.Nodes; using System; using System.Collections.Generic; @@ -13,9 +15,9 @@ public class ElementBindingData : IJSAMObject private BuiltInParameterGroup builtInParameterGroup; private bool instance; - public ElementBindingData(JObject jObject) + public ElementBindingData(JsonObject jObject) { - FromJObject(jObject); + FromJsonObject(jObject); } public ElementBindingData(ElementBindingData elementBindingData) @@ -96,7 +98,7 @@ public bool Instance } } - public bool FromJObject(JObject jObject) + public bool FromJsonObject(JsonObject jObject) { if (jObject == null) { @@ -105,12 +107,12 @@ public bool FromJObject(JObject jObject) if (jObject.ContainsKey("Name")) { - name = jObject.Value("Name"); + name = jObject["Name"]?.GetValue() ?? null; } if (jObject.ContainsKey("BuiltInCategories")) { - JArray jArray = jObject.Value("BuiltInCategories"); + JsonArray jArray = jObject["BuiltInCategories"] as JsonArray; if (jArray != null) { builtInCategories = new HashSet(); @@ -128,7 +130,7 @@ public bool FromJObject(JObject jObject) if (jObject.ContainsKey("BuiltInParameterGroup")) { - string value = jObject.Value("BuiltInParameterGroup"); + string value = jObject["BuiltInParameterGroup"]?.GetValue() ?? null; if (!string.IsNullOrWhiteSpace(value) && Enum.TryParse(value, out BuiltInParameterGroup builtInParameterGroup_Temp)) { builtInParameterGroup = builtInParameterGroup_Temp; @@ -137,15 +139,15 @@ public bool FromJObject(JObject jObject) if (jObject.ContainsKey("Instance")) { - instance = jObject.Value("Instance"); + instance = jObject["Instance"]?.GetValue() ?? default(bool); } return true; } - public JObject ToJObject() + public JsonObject ToJsonObject() { - JObject result = new JObject(); + JsonObject result = new JsonObject(); result.Add("_type", Core.Query.FullTypeName(this)); if (name != null) @@ -155,7 +157,7 @@ public JObject ToJObject() if (builtInCategories != null) { - JArray jArray = new JArray(); + JsonArray jArray = new JsonArray(); foreach (BuiltInCategory builtInCategory in builtInCategories) { jArray.Add(builtInCategory.ToString()); @@ -179,9 +181,9 @@ public class ElementBindingData : IJSAMObject private ForgeTypeId groupTypeId; private bool instance; - public ElementBindingData(JObject jObject) + public ElementBindingData(JsonObject jObject) { - FromJObject(jObject); + FromJsonObject(jObject); } public ElementBindingData(ElementBindingData elementBindingData) @@ -262,7 +264,7 @@ public bool Instance } } - public bool FromJObject(JObject jObject) + public bool FromJsonObject(JsonObject jObject) { if (jObject == null) { @@ -271,12 +273,12 @@ public bool FromJObject(JObject jObject) if (jObject.ContainsKey("Name")) { - name = jObject.Value("Name"); + name = jObject["Name"]?.GetValue() ?? null; } if (jObject.ContainsKey("BuiltInCategories")) { - JArray jArray = jObject.Value("BuiltInCategories"); + JsonArray jArray = jObject["BuiltInCategories"] as JsonArray; if (jArray != null) { builtInCategories = new HashSet(); @@ -294,20 +296,20 @@ public bool FromJObject(JObject jObject) if (jObject.ContainsKey("GroupTypeName")) { - groupTypeId = Query.GroupTypeId(jObject.Value("GroupTypeName")); + groupTypeId = Query.GroupTypeId(jObject["GroupTypeName"]?.GetValue() ?? null); } if (jObject.ContainsKey("Instance")) { - instance = jObject.Value("Instance"); + instance = jObject["Instance"]?.GetValue() ?? default(bool); } return true; } - public JObject ToJObject() + public JsonObject ToJsonObject() { - JObject result = new JObject(); + JsonObject result = new JsonObject(); result.Add("_type", Core.Query.FullTypeName(this)); if (name != null) @@ -317,7 +319,7 @@ public JObject ToJObject() if (builtInCategories != null) { - JArray jArray = new JArray(); + JsonArray jArray = new JsonArray(); foreach (BuiltInCategory builtInCategory in builtInCategories) { jArray.Add(builtInCategory.ToString()); diff --git a/SAM_Revit/SAM.Core.Revit/Classes/RevitInstance.cs b/SAM_Revit/SAM.Core.Revit/Classes/RevitInstance.cs index 0f7eab73..11b8a7a0 100644 --- a/SAM_Revit/SAM.Core.Revit/Classes/RevitInstance.cs +++ b/SAM_Revit/SAM.Core.Revit/Classes/RevitInstance.cs @@ -1,5 +1,6 @@ -using Newtonsoft.Json.Linq; - +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using System.Text.Json.Nodes; namespace SAM.Core.Revit { public class RevitInstance: SAMInstance where T: RevitType @@ -16,23 +17,23 @@ public RevitInstance(T revitType) } - public RevitInstance(JObject jObject) + public RevitInstance(JsonObject jObject) : base(jObject) { } - public override bool FromJObject(JObject jObject) + public override bool FromJsonObject(JsonObject jObject) { - if (!base.FromJObject(jObject)) + if (!base.FromJsonObject(jObject)) return false; return true; } - public override JObject ToJObject() + public override JsonObject ToJsonObject() { - JObject jObject = base.ToJObject(); + JsonObject jObject = base.ToJsonObject(); if (jObject == null) return jObject; diff --git a/SAM_Revit/SAM.Core.Revit/Classes/RevitType.cs b/SAM_Revit/SAM.Core.Revit/Classes/RevitType.cs index 9154287c..bcb55638 100644 --- a/SAM_Revit/SAM.Core.Revit/Classes/RevitType.cs +++ b/SAM_Revit/SAM.Core.Revit/Classes/RevitType.cs @@ -1,5 +1,6 @@ -using Newtonsoft.Json.Linq; - +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using System.Text.Json.Nodes; namespace SAM.Core.Revit { public class RevitType: SAMType @@ -16,23 +17,23 @@ public RevitType(string name) } - public RevitType(JObject jObject) + public RevitType(JsonObject jObject) : base(jObject) { } - public override bool FromJObject(JObject jObject) + public override bool FromJsonObject(JsonObject jObject) { - if (!base.FromJObject(jObject)) + if (!base.FromJsonObject(jObject)) return false; return true; } - public override JObject ToJObject() + public override JsonObject ToJsonObject() { - JObject jObject = base.ToJObject(); + JsonObject jObject = base.ToJsonObject(); if (jObject == null) return jObject; diff --git a/SAM_Revit/SAM.Core.Revit/Classes/SAMSchema.cs b/SAM_Revit/SAM.Core.Revit/Classes/SAMSchema.cs index c1fb5df3..a3ce22ee 100644 --- a/SAM_Revit/SAM.Core.Revit/Classes/SAMSchema.cs +++ b/SAM_Revit/SAM.Core.Revit/Classes/SAMSchema.cs @@ -1,5 +1,7 @@ -using Autodesk.Revit.DB.ExtensibleStorage; -using Newtonsoft.Json.Linq; +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using Autodesk.Revit.DB.ExtensibleStorage; +using System.Text.Json.Nodes; using System; using System.Collections.Generic; using System.Linq; @@ -37,10 +39,10 @@ public SAMSchema(Guid guid, } - public SAMSchema(JObject jObject) + public SAMSchema(JsonObject jObject) : base(jObject) { - FromJObject(jObject); + FromJsonObject(jObject); } public string VendorId @@ -108,32 +110,32 @@ public virtual Schema GetSchema() return schemaBuilder.Finish(); } - public override bool FromJObject(JObject jObject) + public override bool FromJsonObject(JsonObject jObject) { - if (!base.FromJObject(jObject)) + if (!base.FromJsonObject(jObject)) return false; if (jObject.ContainsKey("VendorId")) - vendorId = jObject.Value("VendorId"); + vendorId = jObject["VendorId"]?.GetValue() ?? null; if (jObject.ContainsKey("ReadAccessLevel")) - readAccessLevel = (AccessLevel)Enum.Parse(typeof(AccessLevel), jObject.Value("ReadAccessLevel")); + readAccessLevel = (AccessLevel)Enum.Parse(typeof(AccessLevel), jObject["ReadAccessLevel"]?.GetValue() ?? null); if (jObject.ContainsKey("WriteAccessLevel")) - writeAccessLevel = (AccessLevel)Enum.Parse(typeof(AccessLevel), jObject.Value("WriteAccessLevel")); + writeAccessLevel = (AccessLevel)Enum.Parse(typeof(AccessLevel), jObject["WriteAccessLevel"]?.GetValue() ?? null); if (jObject.ContainsKey("FieldName")) - fieldName = jObject.Value("FieldName"); + fieldName = jObject["FieldName"]?.GetValue() ?? null; if (jObject.ContainsKey("FieldDocumentation")) - fieldDocumentation = jObject.Value("FieldDocumentation"); + fieldDocumentation = jObject["FieldDocumentation"]?.GetValue() ?? null; return true; } - public override JObject ToJObject() + public override JsonObject ToJsonObject() { - JObject jObject = base.ToJObject(); + JsonObject jObject = base.ToJsonObject(); if (jObject == null) return jObject; @@ -170,7 +172,7 @@ public List GetIJSAMObjects(Autodesk.Revit.DB.Element element) where T : I if (string.IsNullOrWhiteSpace(json)) return null; - JArray jArray = Core.Query.JArray(json); + JsonArray jArray = JsonNode.Parse(json) as JsonArray; if (jArray == null) return null; @@ -191,11 +193,11 @@ public bool SetIJSAMObject(Autodesk.Revit.DB.Element element, IJSAMObject jSAMOb if (element == null || jSAMObject == null || string.IsNullOrEmpty(fieldName)) return false; - JObject jObject = jSAMObject.ToJObject(); + JsonObject jObject = jSAMObject.ToJsonObject(); if (jObject == null) return false; - return Modify.SetJObject(this, element, jObject); + return Modify.SetJsonObject(this, element, jObject); } public List SetIJSAMObjects(Autodesk.Revit.DB.Element element, IEnumerable jSAMObjects) @@ -204,7 +206,7 @@ public List SetIJSAMObjects(Autodesk.Revit.DB.Element element, IEnumerable return null; List result = new List(); - JArray jArray = new JArray(); + JsonArray jArray = new JsonArray(); foreach(IJSAMObject iJSAMObject in jSAMObjects) { if (iJSAMObject == null) @@ -213,7 +215,7 @@ public List SetIJSAMObjects(Autodesk.Revit.DB.Element element, IEnumerable continue; } - JObject jObject = iJSAMObject.ToJObject(); + JsonObject jObject = iJSAMObject.ToJsonObject(); if (jObject == null) { result.Add(false); @@ -224,7 +226,7 @@ public List SetIJSAMObjects(Autodesk.Revit.DB.Element element, IEnumerable result.Add(true); } - if (!Modify.SetJArray(this, element, jArray)) + if (!Modify.SetJsonArray(this, element, jArray)) return new List(); return result; @@ -301,4 +303,4 @@ public bool Clear(Autodesk.Revit.DB.Element element) return true; } } -} \ No newline at end of file +} diff --git a/SAM_Revit/SAM.Core.Revit/Classes/ViewSpecificRevitInstance.cs b/SAM_Revit/SAM.Core.Revit/Classes/ViewSpecificRevitInstance.cs index b8a10220..a6964a08 100644 --- a/SAM_Revit/SAM.Core.Revit/Classes/ViewSpecificRevitInstance.cs +++ b/SAM_Revit/SAM.Core.Revit/Classes/ViewSpecificRevitInstance.cs @@ -1,5 +1,6 @@ -using Newtonsoft.Json.Linq; - +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using System.Text.Json.Nodes; namespace SAM.Core.Revit { public class ViewSpecificRevitInstance: RevitInstance where T: RevitType @@ -18,34 +19,34 @@ public ViewSpecificRevitInstance(T revitType, LongId viewId) this.viewId = viewId == null ? null : new LongId(viewId); } - public ViewSpecificRevitInstance(JObject jObject) + public ViewSpecificRevitInstance(JsonObject jObject) : base(jObject) { } - public override bool FromJObject(JObject jObject) + public override bool FromJsonObject(JsonObject jObject) { - if (!base.FromJObject(jObject)) + if (!base.FromJsonObject(jObject)) return false; if (jObject.ContainsKey("ViewId")) { - viewId = new LongId(jObject.Value("ViewId")); + viewId = new LongId(jObject["ViewId"] as JsonObject); } return true; } - public override JObject ToJObject() + public override JsonObject ToJsonObject() { - JObject result = base.ToJObject(); + JsonObject result = base.ToJsonObject(); if (result == null) return result; if (viewId != null) { - result.Add("ViewId", viewId.ToJObject()); + result.Add("ViewId", viewId.ToJsonObject()); } return result; diff --git a/SAM_Revit/SAM.Core.Revit/Modify/SetJArray.cs b/SAM_Revit/SAM.Core.Revit/Modify/SetJArray.cs index fc3c8b90..785a2c9f 100644 --- a/SAM_Revit/SAM.Core.Revit/Modify/SetJArray.cs +++ b/SAM_Revit/SAM.Core.Revit/Modify/SetJArray.cs @@ -1,12 +1,13 @@ -using Autodesk.Revit.DB; +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using Autodesk.Revit.DB; using Autodesk.Revit.DB.ExtensibleStorage; -using Newtonsoft.Json.Linq; - +using System.Text.Json.Nodes; namespace SAM.Core.Revit { public static partial class Modify { - public static bool SetJArray(this SAMSchema sAMSchema, Element element, JArray jArray) + public static bool SetJsonArray(this SAMSchema sAMSchema, Element element, JsonArray jArray) { if (sAMSchema == null || element == null || jArray == null) return false; @@ -15,10 +16,10 @@ public static bool SetJArray(this SAMSchema sAMSchema, Element element, JArray j if (string.IsNullOrWhiteSpace(fieldName)) return false; - return SetJArray(sAMSchema.GetSchema(), element, jArray, fieldName); + return SetJsonArray(sAMSchema.GetSchema(), element, jArray, fieldName); } - public static bool SetJArray(this Schema schema, Element element, JArray jArray, string fieldName) + public static bool SetJsonArray(this Schema schema, Element element, JsonArray jArray, string fieldName) { if (schema == null || element == null || jArray == null) return false; @@ -36,4 +37,4 @@ public static bool SetJArray(this Schema schema, Element element, JArray jArray, return true; } } -} \ No newline at end of file +} diff --git a/SAM_Revit/SAM.Core.Revit/Modify/SetJObject.cs b/SAM_Revit/SAM.Core.Revit/Modify/SetJObject.cs index 3e8eecd9..6f533750 100644 --- a/SAM_Revit/SAM.Core.Revit/Modify/SetJObject.cs +++ b/SAM_Revit/SAM.Core.Revit/Modify/SetJObject.cs @@ -1,12 +1,13 @@ -using Autodesk.Revit.DB; +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using Autodesk.Revit.DB; using Autodesk.Revit.DB.ExtensibleStorage; -using Newtonsoft.Json.Linq; - +using System.Text.Json.Nodes; namespace SAM.Core.Revit { public static partial class Modify { - public static bool SetJObject(this SAMSchema sAMSchema, Element element, JObject jObject) + public static bool SetJsonObject(this SAMSchema sAMSchema, Element element, JsonObject jObject) { if (sAMSchema == null || element == null || jObject == null) return false; @@ -15,10 +16,10 @@ public static bool SetJObject(this SAMSchema sAMSchema, Element element, JObject if (string.IsNullOrWhiteSpace(fieldName)) return false; - return SetJObject(sAMSchema.GetSchema(), element, jObject, fieldName); + return SetJsonObject(sAMSchema.GetSchema(), element, jObject, fieldName); } - public static bool SetJObject(this Schema schema, Element element, JObject jObject, string fieldName) + public static bool SetJsonObject(this Schema schema, Element element, JsonObject jObject, string fieldName) { if (schema == null || element == null || jObject == null) return false; @@ -36,4 +37,4 @@ public static bool SetJObject(this Schema schema, Element element, JObject jObje return true; } } -} \ No newline at end of file +} diff --git a/SAM_Revit/SAM.Core.Revit/Modify/SetValue.cs b/SAM_Revit/SAM.Core.Revit/Modify/SetValue.cs index 9e99f899..f43f6819 100644 --- a/SAM_Revit/SAM.Core.Revit/Modify/SetValue.cs +++ b/SAM_Revit/SAM.Core.Revit/Modify/SetValue.cs @@ -1,4 +1,6 @@ -using Autodesk.Revit.DB; +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using Autodesk.Revit.DB; namespace SAM.Core.Revit { @@ -46,7 +48,7 @@ private static bool SetValue_String(this Parameter parameter, object value) } else if(value is IJSAMObject) { - parameter.Set(((IJSAMObject)value).ToJObject()?.ToString()); + parameter.Set(((IJSAMObject)value).ToJsonObject()?.ToString()); } else { diff --git a/SAM_Revit/SAM.Core.Revit/Properties/AssemblyInfo.cs b/SAM_Revit/SAM.Core.Revit/Properties/AssemblyInfo.cs index 58d7cc42..483fbabc 100644 --- a/SAM_Revit/SAM.Core.Revit/Properties/AssemblyInfo.cs +++ b/SAM_Revit/SAM.Core.Revit/Properties/AssemblyInfo.cs @@ -1,4 +1,7 @@ -/* +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors + +/* * This file is part of the Sustaiable Analytical Model (SAM) * Copyright (c) 2020, the respective contributors. All rights reserved. * diff --git a/SAM_Revit/SAM.Core.Revit/Query/IJSAMObject.cs b/SAM_Revit/SAM.Core.Revit/Query/IJSAMObject.cs index a5bfa879..bdf30f68 100644 --- a/SAM_Revit/SAM.Core.Revit/Query/IJSAMObject.cs +++ b/SAM_Revit/SAM.Core.Revit/Query/IJSAMObject.cs @@ -1,5 +1,7 @@ -using Autodesk.Revit.DB; -using Newtonsoft.Json.Linq; +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using Autodesk.Revit.DB; +using System.Text.Json.Nodes; using System.Collections.Generic; namespace SAM.Core.Revit @@ -11,25 +13,25 @@ public static List IJSAMObjects(this Element element) where T : IJSAMObjec if (element == null) return default; - JToken jToken = element.JToken(); + JsonNode jToken = element.JsonNode(); if (jToken == null) return default; - switch(jToken.Type) + switch(jToken.GetValueKind()) { - case JTokenType.Object: - T t = Core.Create.IJSAMObject(jToken as JObject); + case System.Text.Json.JsonValueKind.Object: + T t = Core.Create.IJSAMObject(jToken as JsonObject); if(t != null) { return new List() { t }; } break; - case JTokenType.Array: - return Core.Create.IJSAMObjects(jToken as JArray); + case System.Text.Json.JsonValueKind.Array: + return Core.Create.IJSAMObjects(jToken as JsonArray); } return null; } } -} \ No newline at end of file +} diff --git a/SAM_Revit/SAM.Core.Revit/Query/JObject.cs b/SAM_Revit/SAM.Core.Revit/Query/JObject.cs index d6ac9122..cbfe035d 100644 --- a/SAM_Revit/SAM.Core.Revit/Query/JObject.cs +++ b/SAM_Revit/SAM.Core.Revit/Query/JObject.cs @@ -1,11 +1,12 @@ -using Autodesk.Revit.DB; -using Newtonsoft.Json.Linq; - +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using Autodesk.Revit.DB; +using System.Text.Json.Nodes; namespace SAM.Core.Revit { public static partial class Query { - public static JToken JToken(this Element element) + public static JsonNode JsonNode(this Element element) { if (element == null) return null; @@ -14,7 +15,7 @@ public static JToken JToken(this Element element) if (string.IsNullOrWhiteSpace(json)) return null; - return Newtonsoft.Json.Linq.JToken.Parse(json); + return System.Text.Json.Nodes.JsonNode.Parse(json); } } -} \ No newline at end of file +} diff --git a/SAM_Revit/SAM.Core.Revit/SAM.Core.Revit.csproj b/SAM_Revit/SAM.Core.Revit/SAM.Core.Revit.csproj index e69eae70..0ff67c53 100644 --- a/SAM_Revit/SAM.Core.Revit/SAM.Core.Revit.csproj +++ b/SAM_Revit/SAM.Core.Revit/SAM.Core.Revit.csproj @@ -8,15 +8,12 @@ net8.0-windows net8.0-windows Library - false false true true SAM_Revit SAM_Revit - Copyright © 2020 - 1.0.%2a - 1.0.%2a + Copyright (c) 2020-2026 Michal Dengusiak & Jakub Ziolkowski and contributors false false Debug;Release;Debug2020;Debug2021;Debug2022;Debug2023;Debug2024;Release2020;Release2021;Release2022;Release2023;Release2024;Debug2025;Release2025;Debug2026;Release2026 @@ -244,9 +241,9 @@ - + - \ No newline at end of file + diff --git a/SAM_Revit/SAM.Geometry.Revit/Classes/FilledRegion.cs b/SAM_Revit/SAM.Geometry.Revit/Classes/FilledRegion.cs index 45347e46..321408ec 100644 --- a/SAM_Revit/SAM.Geometry.Revit/Classes/FilledRegion.cs +++ b/SAM_Revit/SAM.Geometry.Revit/Classes/FilledRegion.cs @@ -1,4 +1,6 @@ -using Newtonsoft.Json.Linq; +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using System.Text.Json.Nodes; using SAM.Core; using SAM.Geometry.Object.Planar; using SAM.Geometry.Planar; @@ -23,7 +25,7 @@ public FilledRegion(FilledRegion filledRegion) { } - public FilledRegion(JObject jObject) + public FilledRegion(JsonObject jObject) : base(jObject) { } @@ -51,24 +53,24 @@ public BoundingBox2D GetBoundingBox(double offset = 0) return new BoundingBox2D(boundingBox2Ds); } - public override bool FromJObject(JObject jObject) + public override bool FromJsonObject(JsonObject jObject) { - if(!base.FromJObject(jObject)) + if(!base.FromJsonObject(jObject)) { return false; } if(jObject.ContainsKey("Face2Ds")) { - face2Ds = Create.ISAMGeometries(jObject.Value("Face2Ds")); + face2Ds = Create.ISAMGeometries(jObject["Face2Ds"] as JsonArray); } return true; } - public override JObject ToJObject() + public override JsonObject ToJsonObject() { - JObject result = base.ToJObject(); + JsonObject result = base.ToJsonObject(); if(result == null) { return result; @@ -76,7 +78,12 @@ public override JObject ToJObject() if(face2Ds != null) { - result.Add("Face2Ds", Create.JArray(face2Ds)); + JsonArray jArray = new JsonArray(); + foreach(Face2D face2D in face2Ds) + { + jArray.Add(face2D?.ToJsonObject()); + } + result.Add("Face2Ds", jArray); } return result; diff --git a/SAM_Revit/SAM.Geometry.Revit/Classes/FilledRegionType.cs b/SAM_Revit/SAM.Geometry.Revit/Classes/FilledRegionType.cs index 68681f5a..bd0c5dea 100644 --- a/SAM_Revit/SAM.Geometry.Revit/Classes/FilledRegionType.cs +++ b/SAM_Revit/SAM.Geometry.Revit/Classes/FilledRegionType.cs @@ -1,5 +1,6 @@ -using Newtonsoft.Json.Linq; - +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using System.Text.Json.Nodes; namespace SAM.Geometry.Revit { public class FilledRegionType : Core.Revit.RevitType @@ -9,7 +10,7 @@ public FilledRegionType(FilledRegionType filledRegionType) { } - public FilledRegionType(JObject jObject) + public FilledRegionType(JsonObject jObject) : base(jObject) { } diff --git a/SAM_Revit/SAM.Geometry.Revit/Classes/RevitInstance2D.cs b/SAM_Revit/SAM.Geometry.Revit/Classes/RevitInstance2D.cs index c6a6a274..68bb0d52 100644 --- a/SAM_Revit/SAM.Geometry.Revit/Classes/RevitInstance2D.cs +++ b/SAM_Revit/SAM.Geometry.Revit/Classes/RevitInstance2D.cs @@ -1,4 +1,6 @@ -using Newtonsoft.Json.Linq; +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using System.Text.Json.Nodes; using SAM.Core.Revit; using SAM.Geometry.Object.Planar; using SAM.Geometry.Planar; @@ -16,7 +18,7 @@ public RevitInstance2D(RevitInstance2D revitInstance2D) } - public RevitInstance2D(JObject jObject) + public RevitInstance2D(JsonObject jObject) : base(jObject) { @@ -35,17 +37,17 @@ public RevitInstance2D(RevitType2D revitType2D, IEnumerable geom } } - public override bool FromJObject(JObject jObject) + public override bool FromJsonObject(JsonObject jObject) { - if (!base.FromJObject(jObject)) + if (!base.FromJsonObject(jObject)) return false; return true; } - public override JObject ToJObject() + public override JsonObject ToJsonObject() { - JObject jObject = base.ToJObject(); + JsonObject jObject = base.ToJsonObject(); if (jObject == null) return jObject; diff --git a/SAM_Revit/SAM.Geometry.Revit/Classes/RevitInstance3D.cs b/SAM_Revit/SAM.Geometry.Revit/Classes/RevitInstance3D.cs index 3b4ae640..bf09c665 100644 --- a/SAM_Revit/SAM.Geometry.Revit/Classes/RevitInstance3D.cs +++ b/SAM_Revit/SAM.Geometry.Revit/Classes/RevitInstance3D.cs @@ -1,4 +1,6 @@ -using Newtonsoft.Json.Linq; +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using System.Text.Json.Nodes; using SAM.Core.Revit; using SAM.Geometry.Object.Spatial; using SAM.Geometry.Spatial; @@ -16,7 +18,7 @@ public RevitInstance3D(RevitInstance3D revitInstance3D) } - public RevitInstance3D(JObject jObject) + public RevitInstance3D(JsonObject jObject) : base(jObject) { @@ -43,9 +45,9 @@ public List Geometries } } - public override bool FromJObject(JObject jObject) + public override bool FromJsonObject(JsonObject jObject) { - if (!base.FromJObject(jObject)) + if (!base.FromJsonObject(jObject)) return false; return true; @@ -61,9 +63,9 @@ public void Move(Vector3D vector3D) geometries = geometries?.ConvertAll(x => x.GetMoved(vector3D)); } - public override JObject ToJObject() + public override JsonObject ToJsonObject() { - JObject jObject = base.ToJObject(); + JsonObject jObject = base.ToJsonObject(); if (jObject == null) return jObject; diff --git a/SAM_Revit/SAM.Geometry.Revit/Classes/RevitType2D.cs b/SAM_Revit/SAM.Geometry.Revit/Classes/RevitType2D.cs index 0428c1b6..8522bfe9 100644 --- a/SAM_Revit/SAM.Geometry.Revit/Classes/RevitType2D.cs +++ b/SAM_Revit/SAM.Geometry.Revit/Classes/RevitType2D.cs @@ -1,4 +1,6 @@ -using Newtonsoft.Json.Linq; +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using System.Text.Json.Nodes; using SAM.Core.Revit; namespace SAM.Geometry.Revit @@ -17,23 +19,23 @@ public RevitType2D(string name) } - public RevitType2D(JObject jObject) + public RevitType2D(JsonObject jObject) : base(jObject) { } - public override bool FromJObject(JObject jObject) + public override bool FromJsonObject(JsonObject jObject) { - if (!base.FromJObject(jObject)) + if (!base.FromJsonObject(jObject)) return false; return true; } - public override JObject ToJObject() + public override JsonObject ToJsonObject() { - JObject jObject = base.ToJObject(); + JsonObject jObject = base.ToJsonObject(); if (jObject == null) return jObject; diff --git a/SAM_Revit/SAM.Geometry.Revit/Classes/RevitType3D.cs b/SAM_Revit/SAM.Geometry.Revit/Classes/RevitType3D.cs index df8667e2..d68738d1 100644 --- a/SAM_Revit/SAM.Geometry.Revit/Classes/RevitType3D.cs +++ b/SAM_Revit/SAM.Geometry.Revit/Classes/RevitType3D.cs @@ -1,4 +1,6 @@ -using Newtonsoft.Json.Linq; +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using System.Text.Json.Nodes; using SAM.Core.Revit; namespace SAM.Geometry.Revit @@ -17,23 +19,23 @@ public RevitType3D(string name) } - public RevitType3D(JObject jObject) + public RevitType3D(JsonObject jObject) : base(jObject) { } - public override bool FromJObject(JObject jObject) + public override bool FromJsonObject(JsonObject jObject) { - if (!base.FromJObject(jObject)) + if (!base.FromJsonObject(jObject)) return false; return true; } - public override JObject ToJObject() + public override JsonObject ToJsonObject() { - JObject jObject = base.ToJObject(); + JsonObject jObject = base.ToJsonObject(); if (jObject == null) return jObject; diff --git a/SAM_Revit/SAM.Geometry.Revit/Classes/Tag.cs b/SAM_Revit/SAM.Geometry.Revit/Classes/Tag.cs index ff58504c..0fc4f077 100644 --- a/SAM_Revit/SAM.Geometry.Revit/Classes/Tag.cs +++ b/SAM_Revit/SAM.Geometry.Revit/Classes/Tag.cs @@ -1,4 +1,6 @@ -using Newtonsoft.Json.Linq; +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using System.Text.Json.Nodes; using SAM.Core; using SAM.Core.Revit; @@ -16,7 +18,7 @@ public Tag(Tag tag) { } - public Tag(JObject jObject) + public Tag(JsonObject jObject) : base(jObject) { @@ -38,39 +40,39 @@ public Tag(TagType tagType, LongId viewId, Planar.Point2D location, Planar.Point this.end = end == null ? null : new Planar.Point2D(end); } - public override bool FromJObject(JObject jObject) + public override bool FromJsonObject(JsonObject jObject) { - if(!base.FromJObject(jObject)) + if(!base.FromJsonObject(jObject)) { return false; } if (jObject.ContainsKey("Location")) { - location = new Planar.Point2D(jObject.Value("Location")); + location = new Planar.Point2D(jObject["Location"] as JsonObject); } if (jObject.ContainsKey("Elbow")) { - elbow = new Planar.Point2D(jObject.Value("Elbow")); + elbow = new Planar.Point2D(jObject["Elbow"] as JsonObject); } if (jObject.ContainsKey("End")) { - end = new Planar.Point2D(jObject.Value("End")); + end = new Planar.Point2D(jObject["End"] as JsonObject); } if (jObject.ContainsKey("ReferenceId")) { - referenceId = new LongId(jObject.Value("ReferenceId")); + referenceId = new LongId(jObject["ReferenceId"] as JsonObject); } return true; } - public override JObject ToJObject() + public override JsonObject ToJsonObject() { - JObject result = base.ToJObject(); + JsonObject result = base.ToJsonObject(); if(result == null) { return null; @@ -78,22 +80,22 @@ public override JObject ToJObject() if(location != null) { - result.Add("Location", location.ToJObject()); + result.Add("Location", location.ToJsonObject()); } if (elbow != null) { - result.Add("Elbow", elbow.ToJObject()); + result.Add("Elbow", elbow.ToJsonObject()); } if (end != null) { - result.Add("End", end.ToJObject()); + result.Add("End", end.ToJsonObject()); } if (referenceId != null) { - result.Add("ReferenceId", referenceId.ToJObject()); + result.Add("ReferenceId", referenceId.ToJsonObject()); } return result; diff --git a/SAM_Revit/SAM.Geometry.Revit/Classes/TagType.cs b/SAM_Revit/SAM.Geometry.Revit/Classes/TagType.cs index ef719769..135d487d 100644 --- a/SAM_Revit/SAM.Geometry.Revit/Classes/TagType.cs +++ b/SAM_Revit/SAM.Geometry.Revit/Classes/TagType.cs @@ -1,4 +1,6 @@ -using Newtonsoft.Json.Linq; +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using System.Text.Json.Nodes; using SAM.Core.Revit; namespace SAM.Geometry.Revit @@ -10,7 +12,7 @@ public TagType(TagType tagType) { } - public TagType(JObject jObject) + public TagType(JsonObject jObject) : base(jObject) { } diff --git a/SAM_Revit/SAM.Geometry.Revit/Properties/AssemblyInfo.cs b/SAM_Revit/SAM.Geometry.Revit/Properties/AssemblyInfo.cs index 9e3bac08..29cc1540 100644 --- a/SAM_Revit/SAM.Geometry.Revit/Properties/AssemblyInfo.cs +++ b/SAM_Revit/SAM.Geometry.Revit/Properties/AssemblyInfo.cs @@ -1,4 +1,7 @@ -/* +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors + +/* * This file is part of the Sustaiable Analytical Model (SAM) * Copyright (c) 2020, the respective contributors. All rights reserved. * diff --git a/SAM_Revit/SAM.Geometry.Revit/SAM.Geometry.Revit.csproj b/SAM_Revit/SAM.Geometry.Revit/SAM.Geometry.Revit.csproj index 0313fcf4..4948ca88 100644 --- a/SAM_Revit/SAM.Geometry.Revit/SAM.Geometry.Revit.csproj +++ b/SAM_Revit/SAM.Geometry.Revit/SAM.Geometry.Revit.csproj @@ -8,13 +8,10 @@ net8.0-windows net8.0-windows Library - false false SAM_Revit SAM_Revit - Copyright © 2020 - 1.0.%2a - 1.0.%2a + Copyright (c) 2020-2026 Michal Dengusiak & Jakub Ziolkowski and contributors false false Debug;Release;Debug2020;Debug2021;Debug2022;Debug2023;Debug2024;Release2020;Release2021;Release2022;Release2023;Release2024;Debug2025;Release2025;Debug2026;Release2026 @@ -252,6 +249,7 @@ - + + - \ No newline at end of file + diff --git a/SAM_Revit/SAM.Units.Revit/Properties/AssemblyInfo.cs b/SAM_Revit/SAM.Units.Revit/Properties/AssemblyInfo.cs index 59e398d0..272fed4a 100644 --- a/SAM_Revit/SAM.Units.Revit/Properties/AssemblyInfo.cs +++ b/SAM_Revit/SAM.Units.Revit/Properties/AssemblyInfo.cs @@ -1,4 +1,7 @@ -/* +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors + +/* * This file is part of the Sustaiable Analytical Model (SAM) * Copyright (c) 2020, the respective contributors. All rights reserved. * diff --git a/SAM_Revit/SAM.Units.Revit/SAM.Units.Revit.csproj b/SAM_Revit/SAM.Units.Revit/SAM.Units.Revit.csproj index f16e6211..3960d58d 100644 --- a/SAM_Revit/SAM.Units.Revit/SAM.Units.Revit.csproj +++ b/SAM_Revit/SAM.Units.Revit/SAM.Units.Revit.csproj @@ -8,13 +8,10 @@ net8.0-windows net8.0-windows Library - false false SAM_Revit SAM_Revit - Copyright © 2020 - 1.0.%2a - 1.0.%2a + Copyright (c) 2020-2026 Michal Dengusiak & Jakub Ziolkowski and contributors false false Debug;Release;Debug2023;Debug2020;Debug2021;Debug2022;Debug2024;Release2020;Release2021;Release2022;Release2023;Release2024;Debug2025;Release2025;Debug2026;Release2026 @@ -22,7 +19,6 @@ ..\..\build\ 9999 - ..\..\build\ @@ -61,7 +57,6 @@ $(SolutionDir)\references\Revit 2020\Revit.exe ..\..\build\SAM.Units.Revit.xml 9999 - true @@ -70,7 +65,6 @@ ..\..\build\SAM.Units.Revit.xml MinimumRecommendedRules.ruleset 9999 - ..\..\build\ @@ -78,7 +72,6 @@ true MinimumRecommendedRules.ruleset 9999 - ..\..\build\ @@ -86,7 +79,6 @@ true MinimumRecommendedRules.ruleset 9999 - true @@ -95,7 +87,6 @@ ..\..\build\SAM.Units.Revit.xml MinimumRecommendedRules.ruleset 9999 - ..\..\build\ @@ -103,7 +94,6 @@ true MinimumRecommendedRules.ruleset 9999 - true @@ -112,7 +102,6 @@ ..\..\build\SAM.Units.Revit.xml MinimumRecommendedRules.ruleset 9999 - ..\..\build\ @@ -120,7 +109,6 @@ true MinimumRecommendedRules.ruleset 9999 - true @@ -129,7 +117,6 @@ ..\..\build\SAM.Units.Revit.xml MinimumRecommendedRules.ruleset 9999 - true @@ -138,7 +125,6 @@ ..\..\build\SAM.Units.Revit.xml MinimumRecommendedRules.ruleset 9999 - true @@ -147,7 +133,6 @@ ..\..\build\SAM.Units.Revit.xml MinimumRecommendedRules.ruleset 9999 - ..\..\build\ @@ -155,7 +140,6 @@ true MinimumRecommendedRules.ruleset 9999 - ..\..\build\ @@ -163,7 +147,6 @@ true MinimumRecommendedRules.ruleset 9999 - ..\..\build\ @@ -171,15 +154,13 @@ true MinimumRecommendedRules.ruleset 9999 - 9999 - - + @@ -267,4 +248,4 @@ False - \ No newline at end of file +