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
@@ -29,6 +29,7 @@ using Autodesk.Revit;
using Autodesk.Revit.DB.Architecture;
using System.Drawing.Design;
using System.ComponentModel;
using System.Transactions;
namespace Revit.SDK.Samples.NewHostedSweep.CS
{
@@ -57,11 +58,6 @@ namespace Revit.SDK.Samples.NewHostedSweep.CS
/// </summary>
private UIDocument m_rvtUIDoc;
/// <summary>
/// Sub transaction
/// </summary>
Transaction m_transaction;
/// <summary>
/// Constructor with HostedSweep and CreationData as parameters.
@@ -75,8 +71,6 @@ namespace Revit.SDK.Samples.NewHostedSweep.CS
m_elemToModify = elem;
m_creationData = creationData;
m_transaction = new Transaction(m_rvtDoc, "External Tool");
m_creationData.EdgeAdded +=
new CreationData.EdgeEventHandler(m_creationData_EdgeAdded);
m_creationData.EdgeRemoved +=
@@ -102,15 +96,18 @@ namespace Revit.SDK.Samples.NewHostedSweep.CS
/// <param name="sym"></param>
private void m_creationData_SymbolChanged(ElementType sym)
{
try
using (var transaction = new Autodesk.Revit.DB.Transaction(m_rvtDoc, "External Tool"))
{
StartTransaction();
m_elemToModify.ChangeTypeId(sym.Id);
CommitTransaction();
}
catch
{
RollbackTransaction();
try
{
transaction.Start();
m_elemToModify.ChangeTypeId(sym.Id);
transaction.Commit();
}
catch
{
transaction.RollBack();
}
}
}
@@ -121,15 +118,18 @@ namespace Revit.SDK.Samples.NewHostedSweep.CS
/// <param name="edge"></param>
private void m_creationData_EdgeRemoved(Edge edge)
{
try
using (var transaction = new Autodesk.Revit.DB.Transaction(m_rvtDoc, "External Tool"))
{
StartTransaction();
m_elemToModify.RemoveSegment(edge.Reference);
CommitTransaction();
}
catch
{
RollbackTransaction();
try
{
transaction.Start();
m_elemToModify.RemoveSegment(edge.Reference);
transaction.Commit();
}
catch
{
transaction.RollBack();
}
}
}
@@ -139,26 +139,29 @@ namespace Revit.SDK.Samples.NewHostedSweep.CS
/// <param name="edge"></param>
private void m_creationData_EdgeAdded(Edge edge)
{
try
{
StartTransaction();
if (m_elemToModify is Fascia)
{
(m_elemToModify as Fascia).AddSegment(edge.Reference);
}
else if (m_elemToModify is Gutter)
{
(m_elemToModify as Gutter).AddSegment(edge.Reference);
}
else if (m_elemToModify is SlabEdge)
{
(m_elemToModify as SlabEdge).AddSegment(edge.Reference);
}
CommitTransaction();
}
catch
using (var transaction = new Autodesk.Revit.DB.Transaction(m_rvtDoc, "External Tool"))
{
RollbackTransaction();
try
{
transaction.Start();
if (m_elemToModify is Fascia)
{
(m_elemToModify as Fascia).AddSegment(edge.Reference);
}
else if (m_elemToModify is Gutter)
{
(m_elemToModify as Gutter).AddSegment(edge.Reference);
}
else if (m_elemToModify is SlabEdge)
{
(m_elemToModify as SlabEdge).AddSegment(edge.Reference);
}
transaction.Commit();
}
catch
{
transaction.RollBack();
}
}
}
@@ -167,15 +170,19 @@ namespace Revit.SDK.Samples.NewHostedSweep.CS
/// </summary>
public void ShowElement()
{
try
using (var transaction = new Autodesk.Revit.DB.Transaction(m_rvtDoc, "External Tool"))
{
StartTransaction();
m_rvtUIDoc.ShowElements(m_elemToModify);
CommitTransaction();
}
catch
{
RollbackTransaction();
try
{
transaction.Start();
m_rvtUIDoc.ShowElements(m_elemToModify);
transaction.Commit();
}
catch
{
transaction.RollBack();
}
}
}
@@ -208,19 +215,22 @@ namespace Revit.SDK.Samples.NewHostedSweep.CS
}
set
{
try
using (var transaction = new Autodesk.Revit.DB.Transaction(m_rvtDoc, "External Tool"))
{
StartTransaction();
Parameter angle = GetParameter("Angle");
if (angle != null)
angle.SetValueString(value);
else
m_elemToModify.Angle = double.Parse(value);
CommitTransaction();
}
catch
{
RollbackTransaction();
try
{
transaction.Start();
Parameter angle = GetParameter("Angle");
if (angle != null)
angle.SetValueString(value);
else
m_elemToModify.Angle = double.Parse(value);
transaction.Commit();
}
catch
{
transaction.RollBack();
}
}
}
}
@@ -267,15 +277,19 @@ namespace Revit.SDK.Samples.NewHostedSweep.CS
{
if (value != m_elemToModify.HorizontalFlipped)
{
try
using (var transaction = new Autodesk.Revit.DB.Transaction(m_rvtDoc, "External Tool"))
{
StartTransaction();
m_elemToModify.HorizontalFlip();
CommitTransaction();
}
catch
{
RollbackTransaction();
try
{
transaction.Start();
m_elemToModify.HorizontalFlip();
transaction.Commit();
}
catch
{
transaction.RollBack();
}
}
}
}
@@ -297,19 +311,22 @@ namespace Revit.SDK.Samples.NewHostedSweep.CS
}
set
{
try
{
StartTransaction();
Parameter horiOff = GetParameter("Horizontal Profile Offset");
if (horiOff != null)
horiOff.SetValueString(value);
else
m_elemToModify.HorizontalOffset = double.Parse(value);
CommitTransaction();
}
catch
{
RollbackTransaction();
using (var transaction = new Autodesk.Revit.DB.Transaction(m_rvtDoc, "External Tool"))
{
try
{
transaction.Start();
Parameter horiOff = GetParameter("Horizontal Profile Offset");
if (horiOff != null)
horiOff.SetValueString(value);
else
m_elemToModify.HorizontalOffset = double.Parse(value);
transaction.Commit();
}
catch
{
transaction.RollBack();
}
}
}
}
@@ -328,15 +345,19 @@ namespace Revit.SDK.Samples.NewHostedSweep.CS
{
if (value != m_elemToModify.VerticalFlipped)
{
try
using (var transaction = new Autodesk.Revit.DB.Transaction(m_rvtDoc, "External Tool"))
{
StartTransaction();
m_elemToModify.VerticalFlip();
CommitTransaction();
}
catch
{
RollbackTransaction();
try
{
transaction.Start();
m_elemToModify.VerticalFlip();
transaction.Commit();
}
catch
{
transaction.RollBack();
}
}
}
}
@@ -358,19 +379,22 @@ namespace Revit.SDK.Samples.NewHostedSweep.CS
}
set
{
try
using (var transaction = new Autodesk.Revit.DB.Transaction(m_rvtDoc, "External Tool"))
{
StartTransaction();
Parameter vertOff = GetParameter("Vertical Profile Offset");
if (vertOff != null)
vertOff.SetValueString(value);
else
m_elemToModify.VerticalOffset = double.Parse(value);
CommitTransaction();
}
catch
{
RollbackTransaction();
try
{
transaction.Start();
Parameter vertOff = GetParameter("Vertical Profile Offset");
if (vertOff != null)
vertOff.SetValueString(value);
else
m_elemToModify.VerticalOffset = double.Parse(value);
transaction.Commit();
}
catch
{
transaction.RollBack();
}
}
}
}
@@ -384,21 +408,5 @@ namespace Revit.SDK.Samples.NewHostedSweep.CS
{
return m_elemToModify.LookupParameter(name);
}
public TransactionStatus StartTransaction()
{
return m_transaction.Start();
}
public TransactionStatus CommitTransaction()
{
return m_transaction.Commit();
}
public TransactionStatus RollbackTransaction()
{
return m_transaction.RollBack();
}
}
}
@@ -35,9 +35,12 @@ namespace Revit.SDK.Samples.NewHostedSweep.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_centerMatrix != null)
m_centerMatrix.Dispose();
}
base.Dispose(disposing);
}
@@ -396,7 +396,7 @@ namespace Revit.SDK.Samples.NewHostedSweep.CS
ExtractCheckedEdgesAndSelectedSymbol();
if (m_creationData.EdgesForHostedSweep.Count == 0)
{
TaskDialog.Show("Revit", "At least one edge should be selected!");
Autodesk.Revit.UI.TaskDialog.Show("Revit", "At least one edge should be selected!");
return;
}
this.DialogResult = DialogResult.OK;
+5 -2
View File
@@ -35,9 +35,12 @@ namespace Revit.SDK.Samples.NewHostedSweep.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_binding != null)
m_binding.Dispose();
}
base.Dispose(disposing);
}
@@ -227,7 +227,7 @@ namespace Revit.SDK.Samples.NewHostedSweep.CS
/// and indicates whether the edge is selected or highlighted.
/// </summary>
public class EdgeBinding : IDisposable
{
{
/// <summary>
/// Edge points in world coordinate system of Revit.
/// </summary>
@@ -386,16 +386,25 @@ namespace Revit.SDK.Samples.NewHostedSweep.CS
#region IDisposable Members
/// <summary>
/// Dispose
/// </summary>
protected virtual void Dispose(bool disposing)
{
if (disposing)
{
if (m_gdiEdge != null)
m_gdiEdge.Dispose();
if (m_pen != null)
m_pen.Dispose();
if (m_region != null)
m_region.Dispose();
}
}
public void Dispose()
{
m_gdiEdge.Dispose();
m_pen.Dispose();
m_region.Dispose();
Dispose(disposing: true);
GC.SuppressFinalize(this);
}
#endregion
}
}
}
@@ -1,105 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project Sdk="">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{BB5C52F3-93FC-441C-91D4-758182CC2747}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Revit.SDK.Samples.NewHostedSweep.CS</RootNamespace>
<AssemblyName>NewHostedSweep</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>
<DocumentationFile>
</DocumentationFile>
<RunCodeAnalysis>false</RunCodeAnalysis>
</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>
<EnableDefaultEmbeddedResourceItems>false</EnableDefaultEmbeddedResourceItems>
</PropertyGroup>
<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="Data\CreationData.cs" />
<Compile Include="Forms\CreationDataTypeConvertor.cs" />
<Compile Include="Creators\CreationMgr.cs" />
<Compile Include="Forms\EdgeFormUITypeEditor.cs" />
<Compile Include="Geom\ElementGeometry.cs" />
<Compile Include="Creators\FasciaCreator.cs" />
<Compile Include="Forms\MainForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\MainForm.Designer.cs">
<DependentUpon>MainForm.cs</DependentUpon>
</Compile>
<Compile Include="Creators\GutterCreator.cs" />
<Compile Include="Creators\HostedSweepCreator.cs" />
<Compile Include="Forms\HostedSweepModifyForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\HostedSweepModifyForm.Designer.cs">
<DependentUpon>HostedSweepModifyForm.cs</DependentUpon>
</Compile>
<Compile Include="Forms\EdgeFetchForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\EdgeFetchForm.Designer.cs">
<DependentUpon>EdgeFetchForm.cs</DependentUpon>
</Compile>
<Compile Include="Data\ModificationData.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Creators\SlabEdgeCreator.cs" />
<Compile Include="Geom\TrackBall.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="Images\CBChecked.bmp" />
<Content Include="Images\CBIndeterminate.bmp" />
<Content Include="Images\CBUnchecked.bmp" />
<EmbeddedResource Include="Forms\MainForm.resx">
<SubType>Designer</SubType>
<DependentUpon>MainForm.cs</DependentUpon>
@@ -113,19 +29,7 @@
<DependentUpon>EdgeFetchForm.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Content Include="Images\CBChecked.bmp" />
<Content Include="Images\CBIndeterminate.bmp" />
<Content Include="Images\CBUnchecked.bmp" />
</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>
@@ -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")]