c # - Revit api - archivo .csproj del complemento de múltiples versiones

Sep 22 2020

Estoy tratando de crear un hello Worldcomplemento simple de múltiples versiones para Revit y encontré este artículo que estoy tratando de seguir. sin embargo, no voy a llegar muy lejos. No estoy tan familiarizado con el funcionamiento del archivo .csproj. He creado complementos antes para años individuales de Revit, pero no para múltiples versiones.

Aquí está mi código .csProj a continuación. Estoy tratando de comenzar poco a poco y solo manejar .net framework 4.5.2 que es Revit 2018. También encontrará fragmentos en la parte inferior de las propiedades de mi proyecto. Ya no hay un abierto para, Start External Application: así que no sé cómo depurarlo a través de Revit.

Se agradece cualquier ayuda / dirección.

Con el código .csproj actual a continuación, aparece este error emergente:

.csproj

<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <TargetFrameworks>net452<!--;net46;net47--></TargetFrameworks>
        <Configurations>Debug;Release</Configurations>
        <!--<Platforms>x64</Platforms>-->
        <OutputPath>bin\Debug\</OutputPath>
    </PropertyGroup>

    <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|Any CPU' ">      
        <DefineConstants>DEBUG</DefineConstants>
        <Optimize>false</Optimize>
        <OutputPath>bin\Debug\</OutputPath>

        <DebugType>full</DebugType>
        <DebugSymbols>true</DebugSymbols>
    </PropertyGroup>

    <PropertyGroup Condition="'$(Configuration)'=='Release'"> <PlatformTarget>x64</PlatformTarget> <DebugType>none</DebugType> <DebugSymbols>false</DebugSymbols> </PropertyGroup> <PropertyGroup Condition=" '$(TargetFramework)' == 'net452' ">
        <DefineConstants>$(DefineConstants);REVIT2018</DefineConstants> <!--<AssemblyName>helloWorld</AssemblyName>--> </PropertyGroup> <ItemGroup Condition=" '$(TargetFramework)' == 'net452' ">
        <!--<Reference Include="AdWindows">
            <HintPath>......\2018\AdWindows.dll</HintPath>
            <EmbedInteropTypes>false</EmbedInteropTypes>
            <Private>false</Private>
        </Reference>-->
        <Reference Include="RevitAPI">
            <HintPath>C:\Program Files\Autodesk\Revit 2018\RevitAPI.dll</HintPath>          
            <EmbedInteropTypes>false</EmbedInteropTypes>
            <Private>false</Private>
        </Reference>
        <Reference Include="RevitAPIUI">
            <HintPath>C:\Program Files\Autodesk\Revit 2018\RevitAPIUI.dll</HintPath>
            <EmbedInteropTypes>false</EmbedInteropTypes>
            <Private>false</Private>
        </Reference>
    </ItemGroup>

    <ItemGroup>
      <Reference Include="PresentationCore" />
      <Reference Include="System.Windows.Forms" />
    </ItemGroup>
</Project>

fragmentos de propiedades del proyecto

Respuestas

Cflux Sep 22 2020 at 21:47

Gracias a Ehsan por compartir su enlace de Github. Pude resolverlo.

Agregué estas 2 líneas a mi grupo de propiedades con el nombre del ensamblaje.

<TargetFrameworkProfile />
    <TargetFrameworkVersion>v4.8</TargetFrameworkVersion>

y luego agregué estos a continuación en grupos de propiedades separados que parecen permitirme ejecutarlos en diferentes versiones. Solo he probado 2018 y 2019 hasta ahora, pero parece prometedor.

<PropertyGroup Condition="$(Configuration.Contains('2018'))"> <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion> <RevitVersion>2018</RevitVersion> </PropertyGroup> <PropertyGroup Condition="$(Configuration.Contains('2019'))">
    <TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
    <RevitVersion>2019</RevitVersion>
  </PropertyGroup>
  <PropertyGroup Condition="$(Configuration.Contains('2020'))"> <TargetFrameworkVersion>v4.7</TargetFrameworkVersion> <RevitVersion>2020</RevitVersion> </PropertyGroup> <PropertyGroup Condition="$(Configuration.Contains('2021'))">
    <TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
    <RevitVersion>2021</RevitVersion>
  </PropertyGroup>
ThếLong Oct 07 2020 at 16:52

Gracias a tu publicación, he aprendido algo sobre el complemento de múltiples versiones. Ahora, para la pregunta directa, puede depurar su biblioteca de clases iniciando Revit cuando inicie el proceso de depuración. Y la configuración es la siguiente:

  1. establezca su proyecto como proyecto de inicio (haga clic con el botón derecho en el proyecto en el panel "Exploración de soluciones" => Establecer como proyecto de inicio) para que sea el primer proyecto en ejecutarse cuando se depure

  2. Abra la pestaña "Propiedades del proyecto", seleccione "Depurar"

  3. En "Iniciar acción" en Depurar, elija "Iniciar programa externo". luego haga clic en el botón "examinar" para seleccionar el archivo ejecutable de Revit. Por defecto, debería estar en:

    C: \ Archivos de programa \ Autodesk \ your_version_of_revit

  4. Guarde el proceso, cree el proyecto y presione F5 (o cualquier tecla que establezca para la depuración)

Esto es un poco tarde porque ya resolvió su problema, pero espero que pueda ser útil en alguna situación similar.