integrate Revit 2025 SDK

This commit is contained in:
Jeremy Tammik
2024-04-11 13:47:20 +02:00
parent e786953544
commit f414362f2b
889 changed files with 26676 additions and 26865 deletions
+4 -107
View File
@@ -1,119 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{1BB53C76-C784-4490-9CB2-CF9AEC00C3A3}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>NewRoof</RootNamespace>
<AssemblyName>NewRoof</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<Project Sdk="">
<Import Project="$(SolutionDir)VSProps\SDKSamples.Sdk.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup>
<RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Command.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RoofForms\CustomTypeConverter.cs" />
<Compile Include="RoofForms\ExtrusionRoofWrapper.cs" />
<Compile Include="RoofForms\FootPrintRoofWrapper.cs" />
<Compile Include="RoofForms\RoofEditorForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="RoofForms\RoofEditorForm.Designer.cs">
<DependentUpon>RoofEditorForm.cs</DependentUpon>
</Compile>
<Compile Include="RoofForms\RoofForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="RoofForms\RoofForm.Designer.cs">
<DependentUpon>RoofForm.cs</DependentUpon>
</Compile>
<Compile Include="RoofForms\RoofItem.cs" />
<Compile Include="RoofForms\GraphicsControl.cs">
<Compile Update="RoofForms\GraphicsControl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="RoofForms\GraphicsControl.Designer.cs">
<DependentUpon>GraphicsControl.cs</DependentUpon>
</Compile>
<Compile Include="RoofsManager\ExtrusionRoofManager.cs" />
<Compile Include="RoofsManager\FootPrintRoofManager.cs" />
<Compile Include="RoofsManager\RoofsManager.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="RoofForms\RoofEditorForm.resx">
<SubType>Designer</SubType>
<DependentUpon>RoofEditorForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="RoofForms\RoofForm.resx">
<SubType>Designer</SubType>
<DependentUpon>RoofForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="RoofForms\GraphicsControl.resx">
<SubType>Designer</SubType>
<DependentUpon>GraphicsControl.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(SolutionDir)VSProps\SDKSamples.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<Import Project="$(SolutionDir)VSProps\SDKSamples.Sdk.targets" />
<PropertyGroup>
<PostBuildEvent>set FILEFORSAMPLEREG="$(SolutionDir)..\..\..\..\Regression\API\SDKSamples\UpdateSampleDllForRegression.py"
if exist %25FILEFORSAMPLEREG%25 py -3 %25FILEFORSAMPLEREG%25 "$(ProjectPath)" "$(TargetPath)" "$(SolutionDir)"</PostBuildEvent>
@@ -1,5 +1,5 @@
//
// (C) Copyright 2003-2019 by Autodesk, Inc.
// (C) Copyright 2003-2023 by Autodesk, Inc.
//
// Permission to use, copy, modify, and distribute this software in
// object code form for any purpose and without fee is hereby granted,
@@ -32,7 +32,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("NewRoof")]
[assembly: AssemblyCopyright("Copyright © Autodesk, Inc. 2009")]
[assembly: AssemblyCopyright("Copyright © Autodesk, Inc. 2023")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
@@ -55,3 +55,5 @@ using System.Runtime.InteropServices;
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: System.Runtime.Versioning.SupportedOSPlatformAttribute("windows7.0")]
@@ -34,9 +34,14 @@ namespace Revit.SDK.Samples.NewRoof.RoofForms.CS
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
if (disposing)
{
components.Dispose();
if (components != null)
components.Dispose();
if (m_highLightPen != null)
m_highLightPen.Dispose();
if (m_displayPen != null)
m_displayPen.Dispose();
}
base.Dispose(disposing);
}
+5 -2
View File
@@ -35,9 +35,12 @@ namespace Revit.SDK.Samples.NewRoof.RoofForms.CS
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
if (disposing)
{
components.Dispose();
if (components != null)
components.Dispose();
if (m_graphicsControl != null)
m_graphicsControl.Dispose();
}
base.Dispose(disposing);
}
+10 -10
View File
@@ -193,7 +193,7 @@ namespace Revit.SDK.Samples.NewRoof.RoofForms.CS
}
else
{
TaskDialog.Show("Revit", "To edit a roof, you should select a roof or double click a roof in the list first.");
Autodesk.Revit.UI.TaskDialog.Show("Revit", "To edit a roof, you should select a roof or double click a roof in the list first.");
}
}
@@ -213,7 +213,7 @@ namespace Revit.SDK.Samples.NewRoof.RoofForms.CS
Autodesk.Revit.DB.FootPrintRoof roof = m_roofsManager.CreateFootPrintRoof(level, roofType);
if (roof == null)
{
TaskDialog.Show("Revit", "Invalid footprint2");
Autodesk.Revit.UI.TaskDialog.Show("Revit", "Invalid footprint2");
}
else
{
@@ -224,12 +224,12 @@ namespace Revit.SDK.Samples.NewRoof.RoofForms.CS
}
else
{
TaskDialog.Show("Revit", "You should supply footprint to create footprint roof, click select button to select footprint in Revit.");
Autodesk.Revit.UI.TaskDialog.Show("Revit", "You should supply footprint to create footprint roof, click select button to select footprint in Revit.");
}
}
catch (Exception ex)
{
TaskDialog.Show("Revit", ex.Message + " : Footprint must be in closed loops.");
Autodesk.Revit.UI.TaskDialog.Show("Revit", ex.Message + " : Footprint must be in closed loops.");
}
}
@@ -250,7 +250,7 @@ namespace Revit.SDK.Samples.NewRoof.RoofForms.CS
Autodesk.Revit.DB.ExtrusionRoof roof = m_roofsManager.CreateExtrusionRoof(refPlane, level, roofType, m_start, m_end);
if (roof == null)
{
TaskDialog.Show("Revit", "Invalid profile");
Autodesk.Revit.UI.TaskDialog.Show("Revit", "Invalid profile");
}
else
{
@@ -261,12 +261,12 @@ namespace Revit.SDK.Samples.NewRoof.RoofForms.CS
}
else
{
TaskDialog.Show("Revit", "You should supply profile to create extrusion roof, click select button to select profile in Revit.");
Autodesk.Revit.UI.TaskDialog.Show("Revit", "You should supply profile to create extrusion roof, click select button to select profile in Revit.");
}
}
catch (Exception ex)
{
TaskDialog.Show("Revit", ex.Message);
Autodesk.Revit.UI.TaskDialog.Show("Revit", ex.Message);
}
}
@@ -312,7 +312,7 @@ namespace Revit.SDK.Samples.NewRoof.RoofForms.CS
}
catch (Exception ex)
{
TaskDialog.Show("Revit", ex.Message);
Autodesk.Revit.UI.TaskDialog.Show("Revit", ex.Message);
m_roofsManager.AbortTransaction();
}
}
@@ -356,7 +356,7 @@ namespace Revit.SDK.Samples.NewRoof.RoofForms.CS
}
catch
{
TaskDialog.Show("Revit", "You should input a decimal value.");
Autodesk.Revit.UI.TaskDialog.Show("Revit", "You should input a decimal value.");
e.Cancel = true;
}
}
@@ -374,7 +374,7 @@ namespace Revit.SDK.Samples.NewRoof.RoofForms.CS
}
catch
{
TaskDialog.Show("Revit", "You should input a decimal value.");
Autodesk.Revit.UI.TaskDialog.Show("Revit", "You should input a decimal value.");
e.Cancel = true;
}
}
@@ -75,10 +75,10 @@ namespace Revit.SDK.Samples.NewRoof.RoofsManager.CS
extrusionRoof = m_creationDoc.NewExtrusionRoof(profile, refPlane, level, roofType, extrusionStart, extrusionEnd);
createRoofTransaction.Commit();
}
catch (System.Exception e)
catch (System.Exception)
{
createRoofTransaction.RollBack();
throw e;
throw;
}
return extrusionRoof;
@@ -71,10 +71,10 @@ namespace Revit.SDK.Samples.NewRoof.RoofsManager.CS
footprintRoof = m_creationDoc.NewFootPrintRoof(footPrint, level, roofType, out footPrintToModelCurveMapping);
createRoofTransaction.Commit();
}
catch (System.Exception e)
catch (System.Exception)
{
createRoofTransaction.RollBack();
throw e;
throw;
}
return footprintRoof;
@@ -48,7 +48,7 @@ namespace Revit.SDK.Samples.NewRoof.RoofsManager.CS
/// <summary>
/// The RoofsManager is used to manage the operations between Revit and UI.
/// </summary>
public class RoofsManager
public class RoofsManager : IDisposable
{
// To store a reference to the commandData.
ExternalCommandData m_commandData;
@@ -64,21 +64,11 @@ namespace Revit.SDK.Samples.NewRoof.RoofsManager.CS
// To store the selected elements in the Revit
Selection m_selection;
// roofs list
ElementSet m_footPrintRoofs;
ElementSet m_extrusionRoofs;
// To store the footprint roof lines.
Autodesk.Revit.DB.CurveArray m_footPrint;
// To store the profile lines.
Autodesk.Revit.DB.CurveArray m_profile;
// Reference Plane for creating extrusion roof
List<ReferencePlane> m_referencePlanes;
// Transaction for manual mode
Transaction m_transaction;
private Transaction m_transaction;
// Current creating roof kind.
public CreateRoofKind RoofKind;
@@ -94,8 +84,8 @@ namespace Revit.SDK.Samples.NewRoof.RoofsManager.CS
m_roofTypes = new List<RoofType>();
m_referencePlanes = new List<ReferencePlane>();
m_footPrint = new CurveArray();
m_profile = new CurveArray();
FootPrint = new CurveArray();
Profile = new CurveArray();
m_footPrintRoofManager = new FootPrintRoofManager(commandData);
m_extrusionRoofManager = new ExtrusionRoofManager(commandData);
@@ -125,21 +115,21 @@ namespace Revit.SDK.Samples.NewRoof.RoofsManager.CS
m_roofTypes = filteredElementCollector.Cast<RoofType>().ToList<RoofType>();
// FootPrint Roofs
m_footPrintRoofs = new ElementSet();
FootPrintRoofs = new ElementSet();
iter = (new FilteredElementCollector(doc)).OfClass(typeof(FootPrintRoof)).GetElementIterator();
iter.Reset();
while (iter.MoveNext())
{
m_footPrintRoofs.Insert(iter.Current as FootPrintRoof);
FootPrintRoofs.Insert(iter.Current as FootPrintRoof);
}
// Extrusion Roofs
m_extrusionRoofs = new ElementSet();
ExtrusionRoofs = new ElementSet();
iter = (new FilteredElementCollector(doc)).OfClass(typeof(ExtrusionRoof)).GetElementIterator();
iter.Reset();
while (iter.MoveNext())
{
m_extrusionRoofs.Insert(iter.Current as ExtrusionRoof);
ExtrusionRoofs.Insert(iter.Current as ExtrusionRoof);
}
// Reference Planes
@@ -197,46 +187,22 @@ namespace Revit.SDK.Samples.NewRoof.RoofsManager.CS
/// <summary>
/// Get all the footprint roofs in Revit.
/// </summary>
public ElementSet FootPrintRoofs
{
get
{
return m_footPrintRoofs;
}
}
public ElementSet FootPrintRoofs { get; private set; }
/// <summary>
/// Get all the extrusion roofs in Revit.
/// </summary>
public ElementSet ExtrusionRoofs
{
get
{
return m_extrusionRoofs;
}
}
public ElementSet ExtrusionRoofs { get; private set; }
/// <summary>
/// Get the footprint roof lines.
/// </summary>
public CurveArray FootPrint
{
get
{
return m_footPrint;
}
}
public CurveArray FootPrint { get; private set; }
/// <summary>
/// Get the extrusion profile lines.
/// </summary>
public CurveArray Profile
{
get
{
return m_profile;
}
}
public CurveArray Profile { get; private set; }
/// <summary>
/// Select elements in Revit to obtain the footprint roof lines or extrusion profile lines.
@@ -260,7 +226,7 @@ namespace Revit.SDK.Samples.NewRoof.RoofsManager.CS
/// <returns>A curve array to hold the footprint roof lines.</returns>
public CurveArray SelectFootPrint()
{
m_footPrint.Clear();
FootPrint.Clear();
while (true)
{
ElementSet es = new ElementSet();
@@ -288,21 +254,21 @@ namespace Revit.SDK.Samples.NewRoof.RoofsManager.CS
if (wall != null)
{
LocationCurve wallCurve = wall.Location as LocationCurve;
m_footPrint.Append(wallCurve.Curve);
FootPrint.Append(wallCurve.Curve);
continue;
}
ModelCurve modelCurve = element as ModelCurve;
if (modelCurve != null)
{
m_footPrint.Append(modelCurve.GeometryCurve);
FootPrint.Append(modelCurve.GeometryCurve);
}
}
break;
}
else
{
TaskDialogResult result = TaskDialog.Show("Warning", "You should select a curve loop, or a wall loop, or loops combination \r\nof walls and curves to create a footprint roof.", TaskDialogCommonButtons.Ok | TaskDialogCommonButtons.Cancel);
TaskDialogResult result = Autodesk.Revit.UI.TaskDialog.Show("Warning", "You should select a curve loop, or a wall loop, or loops combination \r\nof walls and curves to create a footprint roof.", TaskDialogCommonButtons.Ok | TaskDialogCommonButtons.Cancel);
if (result == TaskDialogResult.Cancel)
{
break;
@@ -312,7 +278,7 @@ namespace Revit.SDK.Samples.NewRoof.RoofsManager.CS
}
return m_footPrint;
return FootPrint;
}
/// <summary>
@@ -324,10 +290,10 @@ namespace Revit.SDK.Samples.NewRoof.RoofsManager.CS
public FootPrintRoof CreateFootPrintRoof(Level level, RoofType roofType)
{
FootPrintRoof roof = null;
roof = m_footPrintRoofManager.CreateFootPrintRoof(m_footPrint, level, roofType);
roof = m_footPrintRoofManager.CreateFootPrintRoof(FootPrint, level, roofType);
if (roof != null)
{
this.m_footPrintRoofs.Insert(roof);
this.FootPrintRoofs.Insert(roof);
}
return roof;
}
@@ -338,7 +304,7 @@ namespace Revit.SDK.Samples.NewRoof.RoofsManager.CS
/// <returns>A curve array to hold the extrusion profile lines.</returns>
public CurveArray SelectProfile()
{
m_profile.Clear();
Profile.Clear();
while (true)
{
m_selection.GetElementIds().Clear();
@@ -359,7 +325,7 @@ namespace Revit.SDK.Samples.NewRoof.RoofsManager.CS
ModelCurve modelCurve = element as ModelCurve;
if (modelCurve != null)
{
m_profile.Append(modelCurve.GeometryCurve);
Profile.Append(modelCurve.GeometryCurve);
continue;
}
}
@@ -367,14 +333,14 @@ namespace Revit.SDK.Samples.NewRoof.RoofsManager.CS
}
else
{
TaskDialogResult result = TaskDialog.Show("Warning", "You should select a connected lines or arcs, \r\nnot closed in a loop to create extrusion roof.", TaskDialogCommonButtons.Ok | TaskDialogCommonButtons.Cancel);
TaskDialogResult result = Autodesk.Revit.UI.TaskDialog.Show("Warning", "You should select a connected lines or arcs, \r\nnot closed in a loop to create extrusion roof.", TaskDialogCommonButtons.Ok | TaskDialogCommonButtons.Cancel);
if (result == TaskDialogResult.Cancel)
{
break;
}
}
}
return m_profile;
return Profile;
}
/// <summary>
@@ -390,10 +356,10 @@ namespace Revit.SDK.Samples.NewRoof.RoofsManager.CS
Level level, RoofType roofType, double extrusionStart, double extrusionEnd)
{
ExtrusionRoof roof = null;
roof = m_extrusionRoofManager.CreateExtrusionRoof(m_profile, refPlane, level, roofType, extrusionStart, extrusionEnd);
roof = m_extrusionRoofManager.CreateExtrusionRoof(Profile, refPlane, level, roofType, extrusionStart, extrusionEnd);
if (roof != null)
{
m_extrusionRoofs.Insert(roof);
ExtrusionRoofs.Insert(roof);
}
return roof;
}
@@ -406,7 +372,7 @@ namespace Revit.SDK.Samples.NewRoof.RoofsManager.CS
{
if (m_transaction.GetStatus() == TransactionStatus.Started)
{
TaskDialog.Show("Revit", "Transaction started already");
Autodesk.Revit.UI.TaskDialog.Show("Revit", "Transaction started already");
}
return m_transaction.Start();
}
@@ -427,5 +393,28 @@ namespace Revit.SDK.Samples.NewRoof.RoofsManager.CS
{
return m_transaction.RollBack();
}
protected virtual void Dispose(bool disposing)
{
if (disposing)
{
if (FootPrintRoofs != null)
FootPrintRoofs.Dispose();
if (ExtrusionRoofs != null)
ExtrusionRoofs.Dispose();
if (FootPrint != null)
FootPrint.Dispose();
if (Profile != null)
Profile.Dispose();
if (m_transaction != null)
m_transaction.Dispose();
}
}
public void Dispose()
{
Dispose(disposing: true);
GC.SuppressFinalize(this);
}
}
}