Atualização de macros do Revit

Se estiver atualizando macros, pode ser necessário algum gerenciamento de arquivos para atualizar e operar corretamente as macros no Revit.

Assegure de familiarizar-se com as alterações no Software Development Kit (SDK) do Revit e com as seguintes informações de atualização de macros.

Atualizar macros no nível do aplicativo

  1. Copiar e colar diretórios de macros para:
    • Windows 11: %ProgramData%\Autodesk\Revit\Macros\2027 Release\Revit\AppHookup
  2. Localize .csproj e faça a seguinte alteração:
    • Altere “<TargetFrameworkVersion>net8.0-windows</TargetFrameworkVersion>” para “<TargetFramework>net10.0-windows</TargetFramework>”.
    • Adicione essa linha a <PropertyGroupCondition=" '$(Platform)' == 'AnyCPU' ">

      <NoWarn>MSB3277</NoWarn >

O seguinte é um exemplo de um novo projeto de macro.
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net10.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>test</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>

Atualizar macros no nível do documento

  1. As macros no nível do documento não são suportadas desde o Revit 2025. Você precisará converter as macros no nível do documento em macros no nível do aplicativo manualmente.
  2. Use uma versão anterior do Revit para abrir um documento e copie o projeto de macro de documento para a pasta de macros do aplicativo.
  3. Atualize o arquivo .csproj.
  4. Altere os nomes dos arquivos. “ThisDocument.cs” para “ThisApplication.cs”, “ThisDocument.Designer.cs” para “ThisApplication.Designer.cs”.
  5. Altere o nome da classe de “ThisDocument” para “ThisApplication” nos arquivos .cs.
  6. Altere o nome da superclasse de “Autodesk.Revit.UI.Macros.DocumentEntryPoint” para “Autodesk.Revit.UI.Macros.ApplicationEntryPoint” no ThisApplication.Designer.cs.
Nota: As macros atualizadas não serão automaticamente carregadas se o Revit já estiver em execução. Para carregar as macros atualizadas, será necessário reiniciar o Revit.