Merge pull request #16 from KonradZaremba/feature/2023
2022 and 2023 support
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DefineConstants>TRACE;DEBUG</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
@@ -34,6 +34,27 @@
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug2023|AnyCPU' Or '$(Configuration)|$(Platform)' == 'Debug2022|AnyCPU' Or '$(Configuration)|$(Platform)' == 'Debug2021|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE,post2021</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug2019|AnyCPU' Or '$(Configuration)|$(Platform)' == 'Debug2020|AnyCPU'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE,pre2021</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="AdWindows, Version=3.0.4.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\ModPlus.Revit.API.2021.1.0.0\lib\AdWindows.dll</HintPath>
|
||||
|
||||
@@ -34,8 +34,12 @@ namespace SampleLibrary
|
||||
[Fact]
|
||||
public void SampleFail()
|
||||
{
|
||||
var feet = UnitUtils.ConvertToInternalUnits(3000, DisplayUnitType.DUT_MILLIMETERS);
|
||||
Assert.Equal(5, feet);
|
||||
#if pre2021
|
||||
var feet = UnitUtils.ConvertToInternalUnits(3000, DisplayUnitType.DUT_MILLIMETERS);
|
||||
#else
|
||||
var feet = UnitUtils.ConvertToInternalUnits(3000, UnitTypeId.Feet);
|
||||
#endif
|
||||
Assert.Equal(5, feet);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -60,12 +64,8 @@ namespace SampleLibrary
|
||||
var wallFaceEdges = face.GetEdgesAsCurveLoops();
|
||||
grossArea = ExporterIFCUtils.ComputeAreaOfCurveLoops(wallFaceEdges);
|
||||
transaction.RollBack();
|
||||
|
||||
}
|
||||
}, doc).Wait();
|
||||
|
||||
|
||||
|
||||
Assert.True(grossArea > 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -47,9 +47,14 @@ namespace SampleLibrary
|
||||
{
|
||||
var wall = fixture.Doc.GetElement(new ElementId(346573));
|
||||
var param = wall.get_Parameter(BuiltInParameter.WALL_BASE_OFFSET);
|
||||
var baseOffset = UnitUtils.ConvertFromInternalUnits(param.AsDouble(), param.DisplayUnitType);
|
||||
|
||||
Assert.Equal(2000, baseOffset);
|
||||
#if pre2021
|
||||
var baseOffset = UnitUtils.ConvertFromInternalUnits(param.AsDouble(), param.DisplayUnitType);
|
||||
#else
|
||||
var baseOffset = UnitUtils.ConvertFromInternalUnits(param.AsDouble(), param.GetUnitTypeId());
|
||||
#endif
|
||||
|
||||
Assert.Equal(2000, baseOffset);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -62,8 +67,13 @@ namespace SampleLibrary
|
||||
foreach(var wall in walls)
|
||||
{
|
||||
var param = wall.get_Parameter(BuiltInParameter.WALL_BASE_OFFSET);
|
||||
var baseOffset = UnitUtils.ConvertToInternalUnits(2000, param.DisplayUnitType);
|
||||
param.Set(baseOffset);
|
||||
|
||||
#if pre2021
|
||||
var baseOffset = UnitUtils.ConvertToInternalUnits(2000, param.DisplayUnitType);
|
||||
#else
|
||||
var baseOffset = UnitUtils.ConvertToInternalUnits(2000, param.GetUnitTypeId());
|
||||
#endif
|
||||
param.Set(baseOffset);
|
||||
}
|
||||
}, fixture.Doc)
|
||||
.Wait(); // Important! Wait for action to finish
|
||||
@@ -71,8 +81,12 @@ namespace SampleLibrary
|
||||
foreach (var wall in walls)
|
||||
{
|
||||
var param = wall.get_Parameter(BuiltInParameter.WALL_BASE_OFFSET);
|
||||
var baseOffset = UnitUtils.ConvertFromInternalUnits(param.AsDouble(), param.DisplayUnitType);
|
||||
Assert.Equal(2000, baseOffset);
|
||||
#if pre2021
|
||||
var baseOffset = UnitUtils.ConvertFromInternalUnits(param.AsDouble(), param.DisplayUnitType);
|
||||
#else
|
||||
var baseOffset = UnitUtils.ConvertFromInternalUnits(param.AsDouble(), param.GetUnitTypeId());
|
||||
#endif
|
||||
Assert.Equal(2000, baseOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+50
-2
@@ -1,7 +1,7 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.30011.22
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.2.32630.192
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "xUnitRevit", "xUnitRevit\xUnitRevit.csproj", "{27A79ACA-7EA8-4406-8BB8-216578CC3AB7}"
|
||||
EndProject
|
||||
@@ -13,12 +13,18 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "xUnitRevitUtils2019", "xUni
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleLibrary", "SampleLibrary\SampleLibrary.csproj", "{C3A8684E-15BB-4B8B-B46C-35ACE3729C35}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "xUnitRevitUtils2023", "xUnitRevitUtils2023\xUnitRevitUtils2023.csproj", "{E0BF38C2-13BC-4ACC-B0F2-4DFE82965DB4}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "xUnitRevitUtils2022", "xUnitRevitUtils2022\xUnitRevitUtils2022.csproj", "{78770414-4F6B-4429-BD8F-F0F64A349551}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug2019|Any CPU = Debug2019|Any CPU
|
||||
Debug2020|Any CPU = Debug2020|Any CPU
|
||||
Debug2021|Any CPU = Debug2021|Any CPU
|
||||
Debug2022|Any CPU = Debug2022|Any CPU
|
||||
Debug2023|Any CPU = Debug2023|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Release2019|Any CPU = Release2019|Any CPU
|
||||
Release2020|Any CPU = Release2020|Any CPU
|
||||
@@ -33,6 +39,10 @@ Global
|
||||
{27A79ACA-7EA8-4406-8BB8-216578CC3AB7}.Debug2020|Any CPU.Build.0 = Debug2020|Any CPU
|
||||
{27A79ACA-7EA8-4406-8BB8-216578CC3AB7}.Debug2021|Any CPU.ActiveCfg = Debug2021|Any CPU
|
||||
{27A79ACA-7EA8-4406-8BB8-216578CC3AB7}.Debug2021|Any CPU.Build.0 = Debug2021|Any CPU
|
||||
{27A79ACA-7EA8-4406-8BB8-216578CC3AB7}.Debug2022|Any CPU.ActiveCfg = Debug2022|Any CPU
|
||||
{27A79ACA-7EA8-4406-8BB8-216578CC3AB7}.Debug2022|Any CPU.Build.0 = Debug2022|Any CPU
|
||||
{27A79ACA-7EA8-4406-8BB8-216578CC3AB7}.Debug2023|Any CPU.ActiveCfg = Debug2023|Any CPU
|
||||
{27A79ACA-7EA8-4406-8BB8-216578CC3AB7}.Debug2023|Any CPU.Build.0 = Debug2023|Any CPU
|
||||
{27A79ACA-7EA8-4406-8BB8-216578CC3AB7}.Release|Any CPU.ActiveCfg = Release2021|Any CPU
|
||||
{27A79ACA-7EA8-4406-8BB8-216578CC3AB7}.Release2019|Any CPU.ActiveCfg = Release2019|Any CPU
|
||||
{27A79ACA-7EA8-4406-8BB8-216578CC3AB7}.Release2019|Any CPU.Build.0 = Release2019|Any CPU
|
||||
@@ -46,6 +56,8 @@ Global
|
||||
{977E0B63-5706-4C2B-9C01-3C02D9EBE377}.Debug2020|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{977E0B63-5706-4C2B-9C01-3C02D9EBE377}.Debug2021|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{977E0B63-5706-4C2B-9C01-3C02D9EBE377}.Debug2021|Any CPU.Build.0 = Debug|Any CPU
|
||||
{977E0B63-5706-4C2B-9C01-3C02D9EBE377}.Debug2022|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{977E0B63-5706-4C2B-9C01-3C02D9EBE377}.Debug2023|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{977E0B63-5706-4C2B-9C01-3C02D9EBE377}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{977E0B63-5706-4C2B-9C01-3C02D9EBE377}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{977E0B63-5706-4C2B-9C01-3C02D9EBE377}.Release2019|Any CPU.ActiveCfg = Release|Any CPU
|
||||
@@ -58,6 +70,8 @@ Global
|
||||
{0DEF0F23-8AE2-461B-B014-8A0DA7494088}.Debug2020|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0DEF0F23-8AE2-461B-B014-8A0DA7494088}.Debug2020|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0DEF0F23-8AE2-461B-B014-8A0DA7494088}.Debug2021|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0DEF0F23-8AE2-461B-B014-8A0DA7494088}.Debug2022|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0DEF0F23-8AE2-461B-B014-8A0DA7494088}.Debug2023|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0DEF0F23-8AE2-461B-B014-8A0DA7494088}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0DEF0F23-8AE2-461B-B014-8A0DA7494088}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{0DEF0F23-8AE2-461B-B014-8A0DA7494088}.Release2019|Any CPU.ActiveCfg = Release|Any CPU
|
||||
@@ -70,6 +84,10 @@ Global
|
||||
{02399359-9CA0-4B47-B467-541E290E700F}.Debug2019|Any CPU.Build.0 = Debug|Any CPU
|
||||
{02399359-9CA0-4B47-B467-541E290E700F}.Debug2020|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{02399359-9CA0-4B47-B467-541E290E700F}.Debug2021|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{02399359-9CA0-4B47-B467-541E290E700F}.Debug2022|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{02399359-9CA0-4B47-B467-541E290E700F}.Debug2022|Any CPU.Build.0 = Debug|Any CPU
|
||||
{02399359-9CA0-4B47-B467-541E290E700F}.Debug2023|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{02399359-9CA0-4B47-B467-541E290E700F}.Debug2023|Any CPU.Build.0 = Debug|Any CPU
|
||||
{02399359-9CA0-4B47-B467-541E290E700F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{02399359-9CA0-4B47-B467-541E290E700F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{02399359-9CA0-4B47-B467-541E290E700F}.Release2019|Any CPU.ActiveCfg = Release|Any CPU
|
||||
@@ -84,6 +102,10 @@ Global
|
||||
{C3A8684E-15BB-4B8B-B46C-35ACE3729C35}.Debug2020|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C3A8684E-15BB-4B8B-B46C-35ACE3729C35}.Debug2021|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{C3A8684E-15BB-4B8B-B46C-35ACE3729C35}.Debug2021|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C3A8684E-15BB-4B8B-B46C-35ACE3729C35}.Debug2022|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{C3A8684E-15BB-4B8B-B46C-35ACE3729C35}.Debug2022|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C3A8684E-15BB-4B8B-B46C-35ACE3729C35}.Debug2023|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{C3A8684E-15BB-4B8B-B46C-35ACE3729C35}.Debug2023|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C3A8684E-15BB-4B8B-B46C-35ACE3729C35}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C3A8684E-15BB-4B8B-B46C-35ACE3729C35}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{C3A8684E-15BB-4B8B-B46C-35ACE3729C35}.Release2019|Any CPU.ActiveCfg = Release|Any CPU
|
||||
@@ -92,6 +114,32 @@ Global
|
||||
{C3A8684E-15BB-4B8B-B46C-35ACE3729C35}.Release2020|Any CPU.Build.0 = Release|Any CPU
|
||||
{C3A8684E-15BB-4B8B-B46C-35ACE3729C35}.Release2021|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C3A8684E-15BB-4B8B-B46C-35ACE3729C35}.Release2021|Any CPU.Build.0 = Release|Any CPU
|
||||
{E0BF38C2-13BC-4ACC-B0F2-4DFE82965DB4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E0BF38C2-13BC-4ACC-B0F2-4DFE82965DB4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E0BF38C2-13BC-4ACC-B0F2-4DFE82965DB4}.Debug2019|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E0BF38C2-13BC-4ACC-B0F2-4DFE82965DB4}.Debug2020|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E0BF38C2-13BC-4ACC-B0F2-4DFE82965DB4}.Debug2021|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E0BF38C2-13BC-4ACC-B0F2-4DFE82965DB4}.Debug2022|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E0BF38C2-13BC-4ACC-B0F2-4DFE82965DB4}.Debug2023|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E0BF38C2-13BC-4ACC-B0F2-4DFE82965DB4}.Debug2023|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E0BF38C2-13BC-4ACC-B0F2-4DFE82965DB4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E0BF38C2-13BC-4ACC-B0F2-4DFE82965DB4}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{E0BF38C2-13BC-4ACC-B0F2-4DFE82965DB4}.Release2019|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E0BF38C2-13BC-4ACC-B0F2-4DFE82965DB4}.Release2020|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E0BF38C2-13BC-4ACC-B0F2-4DFE82965DB4}.Release2021|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{78770414-4F6B-4429-BD8F-F0F64A349551}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{78770414-4F6B-4429-BD8F-F0F64A349551}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{78770414-4F6B-4429-BD8F-F0F64A349551}.Debug2019|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{78770414-4F6B-4429-BD8F-F0F64A349551}.Debug2020|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{78770414-4F6B-4429-BD8F-F0F64A349551}.Debug2021|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{78770414-4F6B-4429-BD8F-F0F64A349551}.Debug2022|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{78770414-4F6B-4429-BD8F-F0F64A349551}.Debug2022|Any CPU.Build.0 = Debug|Any CPU
|
||||
{78770414-4F6B-4429-BD8F-F0F64A349551}.Debug2023|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{78770414-4F6B-4429-BD8F-F0F64A349551}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{78770414-4F6B-4429-BD8F-F0F64A349551}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{78770414-4F6B-4429-BD8F-F0F64A349551}.Release2019|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{78770414-4F6B-4429-BD8F-F0F64A349551}.Release2020|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{78770414-4F6B-4429-BD8F-F0F64A349551}.Release2021|Any CPU.ActiveCfg = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release2021|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
@@ -60,7 +60,7 @@
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release2020|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
@@ -84,7 +84,7 @@
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release2019|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
@@ -93,6 +93,30 @@
|
||||
<StartProgram>$(ProgramW6432)\Autodesk\Revit 2019\Revit.exe</StartProgram>
|
||||
<RevitVersion>2019</RevitVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug2022|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<StartAction>Program</StartAction>
|
||||
<StartProgram>$(ProgramW6432)\Autodesk\Revit 2022\Revit.exe</StartProgram>
|
||||
<RevitVersion>2022</RevitVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug2023|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<StartAction>Program</StartAction>
|
||||
<StartProgram>$(ProgramW6432)\Autodesk\Revit 2023\Revit.exe</StartProgram>
|
||||
<RevitVersion>2023</RevitVersion>
|
||||
</PropertyGroup>
|
||||
<!--END-->
|
||||
<ItemGroup>
|
||||
<Reference Include="PresentationCore" />
|
||||
@@ -113,12 +137,17 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<None Include="config_sample.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="config.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="config_sample.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<!--
|
||||
<None Include="config.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
-->
|
||||
<None Include="xUnitRevit.addin" />
|
||||
</ItemGroup>
|
||||
<!-- SWITCH REVIT NUGETS -->
|
||||
@@ -165,6 +194,34 @@
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
</When>
|
||||
<When Condition="'$(Configuration)' == 'Debug2022' Or '$(Configuration)' == 'Release2022'">
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ModPlus.Revit.API.2022">
|
||||
<Version>1.0.0</Version>
|
||||
<ExcludeAssets>runtime</ExcludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\xUnitRevitUtils2022\xUnitRevitUtils2022.csproj">
|
||||
<Project>{78770414-4F6B-4429-BD8F-F0F64A349551}</Project>
|
||||
<Name>xUnitRevitUtils2022</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
</When>
|
||||
<When Condition="'$(Configuration)' == 'Debug2023' Or '$(Configuration)' == 'Release2023'">
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ModPlus.Revit.API.2023">
|
||||
<Version>1.0.0</Version>
|
||||
<ExcludeAssets>runtime</ExcludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\xUnitRevitUtils2023\xUnitRevitUtils2023.csproj">
|
||||
<Project>{E0BF38C2-13BC-4ACC-B0F2-4DFE82965DB4}</Project>
|
||||
<Name>xUnitRevitUtils2023</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
</When>
|
||||
</Choose>
|
||||
<!--END-->
|
||||
<ItemGroup>
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<PackageProjectUrl>https://github.com/Speckle-Next/xunit-Revit</PackageProjectUrl>
|
||||
<RepositoryUrl>https://github.com/Speckle-Next/xunit-Revit</RepositoryUrl>
|
||||
<PackageTags>xunit revit runner</PackageTags>
|
||||
<Authors>Speckle</Authors>
|
||||
<Company>Speckle</Company>
|
||||
<Description>xUnit runner utilities for Revit 2021</Description>
|
||||
<PackageIconUrl>https://avatars2.githubusercontent.com/u/2092016</PackageIconUrl>
|
||||
<PackageIcon>xunit.png</PackageIcon>
|
||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<AssemblyName>xUnitRevitUtils</AssemblyName>
|
||||
<RootNamespace>xUnitRevitUtils</RootNamespace>
|
||||
<PackageId>xUnitRevitUtils.2021</PackageId>
|
||||
<Version>1.0.4</Version>
|
||||
<AssemblyVersion>1.0.4.0</AssemblyVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ModPlus.Revit.API.2022" Version="1.0.0" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<package >
|
||||
<metadata>
|
||||
<id>xUnitRevitUtils.2023</id>
|
||||
<version>$version$</version>
|
||||
<title>$title$</title>
|
||||
<authors>$author$</authors>
|
||||
<owners>$author$</owners>
|
||||
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
||||
<license type="expression">MIT</license>
|
||||
<projectUrl>https://github.com/Speckle-Next/xunit-Revit</projectUrl>
|
||||
<iconUrl>https://avatars2.githubusercontent.com/u/2092016</iconUrl>
|
||||
<description>$description$</description>
|
||||
<releaseNotes></releaseNotes>
|
||||
<copyright>Copyright 2022</copyright>
|
||||
<tags>xunit revit</tags>
|
||||
<dependencies>
|
||||
<dependency id="ModPlus.Revit.API.2023" version="1.0.0" />
|
||||
<dependency id="xunit" version="2.4.1" />
|
||||
</dependencies>
|
||||
</metadata>
|
||||
</package>
|
||||
@@ -0,0 +1,191 @@
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI;
|
||||
using Autodesk.Revit.UI.Selection;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
|
||||
namespace xUnitRevitUtils
|
||||
{
|
||||
/// <summary>
|
||||
/// Utility class with methods and properties used by the xUnit Revit plugin
|
||||
/// </summary>
|
||||
public static class xru
|
||||
{
|
||||
public static UIApplication Uiapp { get; set; }
|
||||
private static List<Action> Queue { get; set; }
|
||||
private static ExternalEvent EventHandler { get; set; }
|
||||
public static SynchronizationContext UiContext { get; set; }
|
||||
public static void Initialize(UIApplication uiapp, SynchronizationContext uiContext, ExternalEvent eventHandler, List<Action> queue)
|
||||
{
|
||||
Uiapp = uiapp;
|
||||
UiContext = uiContext;
|
||||
EventHandler = eventHandler;
|
||||
Queue = queue;
|
||||
}
|
||||
|
||||
#region utility methods
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns the selected elements in the active document
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static List<Element> GetActiveSelection()
|
||||
{
|
||||
Assert.NotNull(Uiapp);
|
||||
|
||||
if (Uiapp.ActiveUIDocument != null)
|
||||
return Uiapp.ActiveUIDocument.Selection.GetElementIds().Select(x => Uiapp.ActiveUIDocument.Document.GetElement(x)).ToList();
|
||||
return new List<Element>();
|
||||
}
|
||||
/// <summary>
|
||||
/// Opens and activates a document if not open already
|
||||
/// </summary>
|
||||
/// <param name="filePath">Path to the file to open</param>
|
||||
public static Document OpenDoc(string filePath)
|
||||
{
|
||||
Assert.NotNull(Uiapp);
|
||||
Document doc = null;
|
||||
//OpenAndActivateDocument only works if run from the current context
|
||||
UiContext.Send(x => { doc = Uiapp.OpenAndActivateDocument(filePath).Document; }, null);
|
||||
Assert.NotNull(doc);
|
||||
return doc;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new empty document
|
||||
/// </summary>
|
||||
/// <param name="templatePath">Path to the project template</param>
|
||||
/// <param name="filePath">Path where to save the new doc</param>
|
||||
/// <param name="overwrite">If true overwrites existing files with same name</param>
|
||||
/// <returns></returns>
|
||||
public static Document CreateNewDoc(string templatePath, string filePath, bool overwrite = true)
|
||||
{
|
||||
Assert.NotNull(Uiapp);
|
||||
Document doc = null;
|
||||
|
||||
try
|
||||
{
|
||||
if (overwrite && File.Exists(filePath))
|
||||
File.Delete(filePath);
|
||||
}
|
||||
catch { }
|
||||
|
||||
//OpenAndActivateDocument only works if run from the current context
|
||||
UiContext.Send(x =>
|
||||
{
|
||||
//if already open, just use it
|
||||
if (!File.Exists(filePath))
|
||||
{
|
||||
doc = Uiapp.Application.NewProjectDocument(templatePath);
|
||||
doc.SaveAs(filePath);
|
||||
doc.Close();
|
||||
}
|
||||
|
||||
doc = Uiapp.OpenAndActivateDocument(filePath).Document;
|
||||
}
|
||||
, null);
|
||||
Assert.NotNull(doc);
|
||||
return doc;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Runs an Action in a Revit transaction, uses TaskCompletionSource to communicate when done
|
||||
/// </summary>
|
||||
/// <param name="action">Action to run</param>
|
||||
/// <param name="doc">Revit Document</param>
|
||||
/// <param name="transactionName">Transaction Name</param>
|
||||
/// <param name="ignoreWarnings">Enable to swallow all warnings generated by the transaction and prevent them from being raised within Revit</param>
|
||||
/// <returns></returns>
|
||||
public static Task RunInTransaction(Action action, Document doc, string transactionName = "transaction", bool ignoreWarnings = false)
|
||||
{
|
||||
var tcs = new TaskCompletionSource<string>();
|
||||
Queue.Add(new Action(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
using (Transaction transaction = new Transaction(doc, transactionName))
|
||||
{
|
||||
transaction.Start();
|
||||
|
||||
if (ignoreWarnings)
|
||||
{
|
||||
var options = transaction.GetFailureHandlingOptions();
|
||||
options.SetFailuresPreprocessor(new IgnoreAllWarnings());
|
||||
transaction.SetFailureHandlingOptions(options);
|
||||
}
|
||||
|
||||
action.Invoke();
|
||||
transaction.Commit();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
tcs.TrySetException(e);
|
||||
}
|
||||
tcs.TrySetResult("");
|
||||
}));
|
||||
|
||||
EventHandler.Raise();
|
||||
|
||||
return tcs.Task;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Runs an Action, uses TaskCompletionSource to communicate when done
|
||||
/// </summary>
|
||||
/// <param name="action">Action to run</param>
|
||||
/// <param name="doc">Revit Document</param>
|
||||
/// <returns></returns>
|
||||
public static Task Run(Action action, Document doc)
|
||||
{
|
||||
var tcs = new TaskCompletionSource<string>();
|
||||
Queue.Add(new Action(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
action.Invoke();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
tcs.TrySetException(e);
|
||||
}
|
||||
tcs.TrySetResult("");
|
||||
}));
|
||||
|
||||
EventHandler.Raise();
|
||||
|
||||
return tcs.Task;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A failures preprocesser that clears any failures that occur within a transaction
|
||||
/// </summary>
|
||||
internal class IgnoreAllWarnings : IFailuresPreprocessor
|
||||
{
|
||||
public FailureProcessingResult PreprocessFailures(FailuresAccessor failuresAccessor)
|
||||
{
|
||||
var failList = failuresAccessor.GetFailureMessages();
|
||||
|
||||
foreach (FailureMessageAccessor failure in failList)
|
||||
{
|
||||
failuresAccessor.DeleteWarning(failure);
|
||||
}
|
||||
|
||||
return FailureProcessingResult.Continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<PackageProjectUrl>https://github.com/Speckle-Next/xunit-Revit</PackageProjectUrl>
|
||||
<RepositoryUrl>https://github.com/Speckle-Next/xunit-Revit</RepositoryUrl>
|
||||
<PackageTags>xunit revit runner</PackageTags>
|
||||
<Authors>Speckle</Authors>
|
||||
<Company>Speckle</Company>
|
||||
<Description>xUnit runner utilities for Revit 2023</Description>
|
||||
<PackageIconUrl>https://avatars2.githubusercontent.com/u/2092016</PackageIconUrl>
|
||||
<PackageIcon>xunit.png</PackageIcon>
|
||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<AssemblyName>xUnitRevitUtils</AssemblyName>
|
||||
<RootNamespace>xUnitRevitUtils</RootNamespace>
|
||||
<PackageId>xUnitRevitUtils.2023</PackageId>
|
||||
<Version>1.0.4</Version>
|
||||
<AssemblyVersion>1.0.4.0</AssemblyVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ModPlus.Revit.API.2023" Version="1.0.0" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<package >
|
||||
<metadata>
|
||||
<id>xUnitRevitUtils.2023</id>
|
||||
<version>$version$</version>
|
||||
<title>$title$</title>
|
||||
<authors>$author$</authors>
|
||||
<owners>$author$</owners>
|
||||
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
||||
<license type="expression">MIT</license>
|
||||
<projectUrl>https://github.com/Speckle-Next/xunit-Revit</projectUrl>
|
||||
<iconUrl>https://avatars2.githubusercontent.com/u/2092016</iconUrl>
|
||||
<description>$description$</description>
|
||||
<releaseNotes></releaseNotes>
|
||||
<copyright>Copyright 2022</copyright>
|
||||
<tags>xunit revit</tags>
|
||||
<dependencies>
|
||||
<dependency id="ModPlus.Revit.API.2023" version="1.0.0" />
|
||||
<dependency id="xunit" version="2.4.1" />
|
||||
</dependencies>
|
||||
</metadata>
|
||||
</package>
|
||||
@@ -0,0 +1,191 @@
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI;
|
||||
using Autodesk.Revit.UI.Selection;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
|
||||
namespace xUnitRevitUtils
|
||||
{
|
||||
/// <summary>
|
||||
/// Utility class with methods and properties used by the xUnit Revit plugin
|
||||
/// </summary>
|
||||
public static class xru
|
||||
{
|
||||
public static UIApplication Uiapp { get; set; }
|
||||
private static List<Action> Queue { get; set; }
|
||||
private static ExternalEvent EventHandler { get; set; }
|
||||
public static SynchronizationContext UiContext { get; set; }
|
||||
public static void Initialize(UIApplication uiapp, SynchronizationContext uiContext, ExternalEvent eventHandler, List<Action> queue)
|
||||
{
|
||||
Uiapp = uiapp;
|
||||
UiContext = uiContext;
|
||||
EventHandler = eventHandler;
|
||||
Queue = queue;
|
||||
}
|
||||
|
||||
#region utility methods
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns the selected elements in the active document
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static List<Element> GetActiveSelection()
|
||||
{
|
||||
Assert.NotNull(Uiapp);
|
||||
|
||||
if (Uiapp.ActiveUIDocument != null)
|
||||
return Uiapp.ActiveUIDocument.Selection.GetElementIds().Select(x => Uiapp.ActiveUIDocument.Document.GetElement(x)).ToList();
|
||||
return new List<Element>();
|
||||
}
|
||||
/// <summary>
|
||||
/// Opens and activates a document if not open already
|
||||
/// </summary>
|
||||
/// <param name="filePath">Path to the file to open</param>
|
||||
public static Document OpenDoc(string filePath)
|
||||
{
|
||||
Assert.NotNull(Uiapp);
|
||||
Document doc = null;
|
||||
//OpenAndActivateDocument only works if run from the current context
|
||||
UiContext.Send(x => { doc = Uiapp.OpenAndActivateDocument(filePath).Document; }, null);
|
||||
Assert.NotNull(doc);
|
||||
return doc;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new empty document
|
||||
/// </summary>
|
||||
/// <param name="templatePath">Path to the project template</param>
|
||||
/// <param name="filePath">Path where to save the new doc</param>
|
||||
/// <param name="overwrite">If true overwrites existing files with same name</param>
|
||||
/// <returns></returns>
|
||||
public static Document CreateNewDoc(string templatePath, string filePath, bool overwrite = true)
|
||||
{
|
||||
Assert.NotNull(Uiapp);
|
||||
Document doc = null;
|
||||
|
||||
try
|
||||
{
|
||||
if (overwrite && File.Exists(filePath))
|
||||
File.Delete(filePath);
|
||||
}
|
||||
catch { }
|
||||
|
||||
//OpenAndActivateDocument only works if run from the current context
|
||||
UiContext.Send(x =>
|
||||
{
|
||||
//if already open, just use it
|
||||
if (!File.Exists(filePath))
|
||||
{
|
||||
doc = Uiapp.Application.NewProjectDocument(templatePath);
|
||||
doc.SaveAs(filePath);
|
||||
doc.Close();
|
||||
}
|
||||
|
||||
doc = Uiapp.OpenAndActivateDocument(filePath).Document;
|
||||
}
|
||||
, null);
|
||||
Assert.NotNull(doc);
|
||||
return doc;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Runs an Action in a Revit transaction, uses TaskCompletionSource to communicate when done
|
||||
/// </summary>
|
||||
/// <param name="action">Action to run</param>
|
||||
/// <param name="doc">Revit Document</param>
|
||||
/// <param name="transactionName">Transaction Name</param>
|
||||
/// <param name="ignoreWarnings">Enable to swallow all warnings generated by the transaction and prevent them from being raised within Revit</param>
|
||||
/// <returns></returns>
|
||||
public static Task RunInTransaction(Action action, Document doc, string transactionName = "transaction", bool ignoreWarnings = false)
|
||||
{
|
||||
var tcs = new TaskCompletionSource<string>();
|
||||
Queue.Add(new Action(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
using (Transaction transaction = new Transaction(doc, transactionName))
|
||||
{
|
||||
transaction.Start();
|
||||
|
||||
if (ignoreWarnings)
|
||||
{
|
||||
var options = transaction.GetFailureHandlingOptions();
|
||||
options.SetFailuresPreprocessor(new IgnoreAllWarnings());
|
||||
transaction.SetFailureHandlingOptions(options);
|
||||
}
|
||||
|
||||
action.Invoke();
|
||||
transaction.Commit();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
tcs.TrySetException(e);
|
||||
}
|
||||
tcs.TrySetResult("");
|
||||
}));
|
||||
|
||||
EventHandler.Raise();
|
||||
|
||||
return tcs.Task;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Runs an Action, uses TaskCompletionSource to communicate when done
|
||||
/// </summary>
|
||||
/// <param name="action">Action to run</param>
|
||||
/// <param name="doc">Revit Document</param>
|
||||
/// <returns></returns>
|
||||
public static Task Run(Action action, Document doc)
|
||||
{
|
||||
var tcs = new TaskCompletionSource<string>();
|
||||
Queue.Add(new Action(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
action.Invoke();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
tcs.TrySetException(e);
|
||||
}
|
||||
tcs.TrySetResult("");
|
||||
}));
|
||||
|
||||
EventHandler.Raise();
|
||||
|
||||
return tcs.Task;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A failures preprocesser that clears any failures that occur within a transaction
|
||||
/// </summary>
|
||||
internal class IgnoreAllWarnings : IFailuresPreprocessor
|
||||
{
|
||||
public FailureProcessingResult PreprocessFailures(FailuresAccessor failuresAccessor)
|
||||
{
|
||||
var failList = failuresAccessor.GetFailureMessages();
|
||||
|
||||
foreach (FailureMessageAccessor failure in failList)
|
||||
{
|
||||
failuresAccessor.DeleteWarning(failure);
|
||||
}
|
||||
|
||||
return FailureProcessingResult.Continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user