Skip to content

Commit

Permalink
Merge pull request #127 from bvn-architecture/1.11.0-beta
Browse files Browse the repository at this point in the history
v1.11.0 beta
  • Loading branch information
petersmithfromengland authored Nov 6, 2024
2 parents 47b0c4b + 116111d commit 082747d
Show file tree
Hide file tree
Showing 23 changed files with 621 additions and 408 deletions.
2 changes: 1 addition & 1 deletion AddinDeployment/RemoveAddinAllVersions.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

pushd %~dp0

for %%i in (2015 2016 2017 2018 2019 2020 2021 2022 2023 2024) do (
for %%i in (2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025) do (
echo.
echo Removing BatchRvt addin for Revit %%i
call RemoveAddin.bat %%i
Expand Down
4 changes: 2 additions & 2 deletions BatchRevitDynamo/RevitBatchProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public enum UseRevitVersion
Revit2021 = 7,
Revit2022 = 8,
Revit2023 = 9,
Revit2024 = 10

Revit2024 = 10,
Revit2025 = 11
}

/// <summary>
Expand Down
10 changes: 10 additions & 0 deletions BatchRvtAddin2025/BatchRvtAddin2025.addin
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<RevitAddIns>
<AddIn Type="Application">
<Name>BatchRvtAddin</Name>
<Assembly>.\BatchRvt\BatchRvtAddin2025.dll</Assembly>
<AddInId>b57d22c8-5e1f-407a-86ea-a8615fd8df34</AddInId>
<FullClassName>BatchRvt.Addin.Revit2025.BatchRvtAddinApplication</FullClassName>
<VendorId>BATCHRVT</VendorId>
</AddIn>
</RevitAddIns>
58 changes: 58 additions & 0 deletions BatchRvtAddin2025/BatchRvtAddin2025.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0-windows</TargetFramework>
<OutputType>Library</OutputType>
<RootNamespace>BatchRvtAddin2025</RootNamespace>
<AssemblyName>BatchRvtAddin2025</AssemblyName>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>


<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
<Copyright>Copyright © 2024</Copyright>
<Company>BVN</Company>
<Product>BatchRvtAddin2025</Product>
<AssemblyTitle>BatchRvtAddin2025</AssemblyTitle>
<AssemblyVersion>1.0.0</AssemblyVersion>
<FileVersion>1.0.0</FileVersion>

<UseWindowsForms>true</UseWindowsForms>
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
<BaseOutputPath>bin\x64\</BaseOutputPath>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<OutputPath>bin\x64\Release\</OutputPath>
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FluentAssertions">
<Version>6.8.0</Version>
</PackageReference>
<PackageReference Include="IronPython" Version="2.7.12" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Moq">
<Version>4.18.3</Version>
</PackageReference>
<PackageReference Include="Nice3point.Revit.Api.RevitAPI">
<Version>2025.2.0</Version>
</PackageReference>
<PackageReference Include="Nice3point.Revit.Api.RevitAPIUI">
<Version>2025.2.0</Version>
</PackageReference>
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
<PackageReference Include="xunit">
<Version>2.4.2</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BatchRvtScriptHost\BatchRvtScriptHost.csproj" />
<ProjectReference Include="..\BatchRvtUtil\BatchRvtUtil.csproj" />
</ItemGroup>

<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="call &quot;$(ProjectDir)..\AddinDeployment\DeployAddin.bat&quot; &quot;$(ProjectDir)&quot; &quot;$(TargetDir)&quot; &quot;2025&quot;" />
</Target>
</Project>
93 changes: 93 additions & 0 deletions BatchRvtAddin2025/BatchRvtAddinApplication.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
//
// Revit Batch Processor
//
// Copyright (c) 2020 Daniel Rumery, BVN
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
//

using System;
using System.ComponentModel;
using System.IO;
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.UI;
using BatchRvt.ScriptHost;
using WinForms = System.Windows.Forms;

namespace BatchRvt.Addin.Revit2025
{
[Transaction(TransactionMode.Manual)]
[Regeneration(RegenerationOption.Manual)]
[DisplayName("BatchRvtAddin")]
[Description("BatchRvtAddin")]
public class BatchRvtAddinApplication : IExternalApplication
{
public Result OnStartup(UIControlledApplication uiApplication)
{
SetupBatchScriptHost(uiApplication.ControlledApplication);

return Result.Succeeded;
}

public Result OnShutdown(UIControlledApplication application)
{
return Result.Succeeded;
}

private static void SetupBatchScriptHost(ControlledApplication controlledApplication)
{
var pluginFolderPath = Path.GetDirectoryName(typeof(BatchRvtAddinApplication).Assembly.Location);

var batchRvtExternalEventHandler = new BatchRvtExternalEventHandler(pluginFolderPath);

batchRvtExternalEventHandler.Raise();
}
}

public class BatchRvtExternalEventHandler : IExternalEventHandler
{
private readonly ExternalEvent externalEvent_;
private readonly string pluginFolderPath_;

public BatchRvtExternalEventHandler(string pluginFolderPath)
{
externalEvent_ = ExternalEvent.Create(this);
pluginFolderPath_ = pluginFolderPath;
}

public void Execute(UIApplication uiApp)
{
try
{
ScriptHostUtil.ExecuteBatchScriptHost(pluginFolderPath_, uiApp);
}
catch (Exception e)
{
WinForms.MessageBox.Show(e.ToString(), ScriptHostUtil.BATCH_RVT_ERROR_WINDOW_TITLE);
}
}

public string GetName()
{
return "BatchRvt_ExternalEventHandler";
}

public ExternalEventRequest Raise()
{
return externalEvent_.Raise();
}
}
}
8 changes: 8 additions & 0 deletions BatchRvtAddin2025/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"profiles": {
"Revit 2025": {
"commandName": "Executable",
"executablePath": "C:\\Program Files\\Autodesk\\Revit 2025\\Revit.exe"
}
}
}
22 changes: 12 additions & 10 deletions BatchRvtScriptHost/Util/ScriptHostUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Diagnostics;
using System.IO;

namespace BatchRvt.ScriptHost;
Expand Down Expand Up @@ -51,12 +50,13 @@ object uiApplicationObject
engine,
new Dictionary<string, object>
{
{ "__revit__", uiApplicationObject }
{ "__revit__", uiApplicationObject },
});

var mainModuleScope = ScriptUtil.CreateMainModule(engine);

var pluginFullFolderPath = Path.GetFullPath(pluginFolderPath);

var scriptHostFilePath = Path.Combine(batchRvtScriptsFolderPath, BatchScriptHostFilename);
var batchRvtFolderPath = GetBatchRvtFolderPath(environmentVariables);

Expand Down Expand Up @@ -108,18 +108,20 @@ private static string GetEnvironmentVariable(StringDictionary environmentVariabl

private static StringDictionary GetEnvironmentVariables()
{
StringDictionary environmentVariables = null;

// NOTE: Have encountered (at least once) a NullReferenceException upon accessing the EnvironmentVariables property!
try
{
environmentVariables = Process.GetCurrentProcess().StartInfo.EnvironmentVariables;
var environmentVariables = new StringDictionary();
var ev = Environment.GetEnvironmentVariables();
foreach (string key in ev.Keys)
{
environmentVariables[key] = ev[key].ToString();
}

return environmentVariables;
}
catch (NullReferenceException e)
catch (NullReferenceException)
{
environmentVariables = null;
return null;
}

return environmentVariables;
}
}
3 changes: 2 additions & 1 deletion BatchRvtUtil/BatchRvt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ public enum RevitSessionOption
{ RevitVersion.SupportedRevitVersion.Revit2021, "BatchRvtAddin2021.addin" },
{ RevitVersion.SupportedRevitVersion.Revit2022, "BatchRvtAddin2022.addin" },
{ RevitVersion.SupportedRevitVersion.Revit2023, "BatchRvtAddin2023.addin" },
{ RevitVersion.SupportedRevitVersion.Revit2024, "BatchRvtAddin2024.addin" }
{ RevitVersion.SupportedRevitVersion.Revit2024, "BatchRvtAddin2024.addin" },
{ RevitVersion.SupportedRevitVersion.Revit2025, "BatchRvtAddin2025.addin" },
};


Expand Down
Loading

0 comments on commit 082747d

Please sign in to comment.