Revit マクロをアップグレードする

マクロをアップグレードする場合、Revit でマクロを正しく更新して動作させるには、何らかのファイル管理が必要となることがあります。

Revit Software Development Kit (SDK)および次のマクロ更新情報を必ず熟読してください。

アプリケーションレベル マクロのアップグレード

  1. マクロ フォルダをコピーして次の場所に貼り付けます。
    • Windows 7 および Windows 8: %ProgramData%\Autodesk\Revit\Macros\2026 リリース\Revit\AppHookup
  2. .csproj を見つけて、次の変更を行います。
    • 「<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>」を「<TargetFramework>net7.0-windows</TargetFramework>」に変更します。
新規マクロ プロジェクトの例を次に示します。
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net8.0-windows</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
    <PlatformTarget>x64</PlatformTarget>
    <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
    <AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
    <Optimize>False</Optimize>
    <DebugSymbols>True</DebugSymbols>
    <DebugType>Portable</DebugType>
    <OutputPath>..\..\Addin\</OutputPath>
    <AssemblyName>MacroTemplate</AssemblyName>
    <BaseInterMediateOutputPath>obj\</BaseInterMediateOutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <InterMediateOutputPath>obj\Debug</InterMediateOutputPath>
    <Deterministic>false</Deterministic>
    <GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
    <GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
    <GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
    <GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
    <GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
    <GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="..\..\..\..\..\RevitAPI.dll">
      <Private>False</Private>
    </Reference>
    <Reference Include="..\..\..\..\..\RevitAPIUI.dll">
      <Private>False</Private>
    </Reference>
  </ItemGroup>
  <Target Name="PreBuild" BeforeTargets="PreBuildEvent">
    <Exec Command="del $(OutputPath)\*.dll" />
  </Target>
</Project>

ドキュメントレベル マクロのアップグレード

  1. ドキュメントレベル マクロは、Revit 2025 ではサポートされていません。ドキュメントレベル マクロをアプリケーション レベル マクロに手動で変換する必要があります。
  2. 前バージョンの Revit を使用してドキュメントを開き、ドキュメント マクロ プロジェクトをアプリケーション マクロ フォルダにコピーします。
  3. .csproj ファイルを更新します。
  4. ファイル名を変更します。「ThisDocument.cs」から「ThisApplication.cs」に、「ThisDocument.Designer.cs」から「ThisApplication.Designer.cs」に変更します。
  5. .cs ファイルで、クラス名を「ThisDocument」から「ThisApplication」に変更します。
  6. ThisApplication.Designer.cs で、スーパークラス名を「Autodesk.Revit.UI.Macros.DocumentEntryPoint」から「Autodesk.Revit.UI.Macros.ApplicationEntryPoint」に変更します。
注: Revit 2025 でアップグレードしたマクロは、Revit が既に実行されている場合は自動的にロードされません。アップグレードしたマクロをロードするには、Revit を再起動する必要があります。