updated to Revit 2023 SDK

This commit is contained in:
Jeremy Tammik
2022-04-07 09:12:58 +02:00
parent e3434c5200
commit ab02648986
342 changed files with 6496 additions and 3140 deletions
@@ -58,7 +58,7 @@
<AddIn Type="Command">
<Assembly>FabricationPartLayout.dll</Assembly>
<AddInId>b083fe9b-dd69-43f9-b4ba-71d83e783825</AddInId>
<FullClassName>Revit.SDK.Samples.FabricationPartLayout.CS.Ancillaries</FullClassName>
<FullClassName>Revit.SDK.Samples.FabricationPartLayout.CS.Ancillaries</FullClassName>
<VendorId>ADSK</VendorId>
<Text>Ancillaries</Text>
<Description>Discover the Ancillaries Associated with a Fabrication Part</Description>
@@ -264,4 +264,15 @@
<Discipline>Any</Discipline>
<LanguageType>Unknown</LanguageType>
</AddIn>
<AddIn Type="Command">
<Assembly>FabricationPartLayout.dll</Assembly>
<AddInId>0170D9E3-DFA3-4320-B53F-EC3A80DDE514</AddInId>
<FullClassName>Revit.SDK.Samples.FabricationPartLayout.CS.FlipPart</FullClassName>
<VendorId>ADSK</VendorId>
<Text>Flip Part</Text>
<Description>Flips a Fabrication Part to the opposite direction</Description>
<VisibilityMode>AlwaysVisible</VisibilityMode>
<Discipline>Any</Discipline>
<LanguageType>Unknown</LanguageType>
</AddIn>
</RevitAddIns>
@@ -1,10 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
None
</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
</PropertyGroup>
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -31,7 +26,6 @@
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<DocumentationFile>bin\Debug\FabricationPartLayout.XML</DocumentationFile>
<PlatformTarget>x64</PlatformTarget>
<CodeAnalysisRuleSet />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
@@ -43,7 +37,6 @@
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<DocumentationFile>bin\Release\FabricationPartLayout.XML</DocumentationFile>
<PlatformTarget>x64</PlatformTarget>
<CodeAnalysisRuleSet />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
@@ -54,8 +47,7 @@
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>
</CodeAnalysisRuleSet>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
@@ -64,8 +56,7 @@
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>
</CodeAnalysisRuleSet>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<DocumentationFile>bin\x64\Release\FabricationPartLayout.XML</DocumentationFile>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
@@ -101,6 +92,7 @@
<Compile Include="OptimizeStraights.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="StretchAndFit.cs" />
<Compile Include="FlipPart.cs" />
</ItemGroup>
<Import Project="$(SolutionDir)VSProps\SDKSamples.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
@@ -0,0 +1,102 @@
//
// (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,
// provided that the above copyright notice appears in all copies and
// that both that copyright notice and the limited warranty and
// restricted rights notice below appear in all supporting
// documentation.
//
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
// UNINTERRUPTED OR ERROR FREE.
//
// Use, duplication, or disclosure by the U.S. Government is subject to
// restrictions set forth in FAR 52.227-19 (Commercial Computer
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
// (Rights in Technical Data and Computer Software), as applicable.
//
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Autodesk.Revit;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.DB.Fabrication;
using System.Windows.Forms;
using Autodesk.Revit.UI.Selection;
namespace Revit.SDK.Samples.FabricationPartLayout.CS
{
/// <summary>
/// Implements the Revit add-in interface IExternalCommand
/// </summary>
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
[Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)]
public class FlipPart : IExternalCommand
{
/// <summary>
/// Implement this method as an external command for Revit.
/// </summary>
/// <param name="commandData">An object that is passed to the external application
/// which contains data related to the command,
/// such as the application object and active view.</param>
/// <param name="message">A message that can be set by the external application
/// which will be displayed if a failure or cancellation is returned by
/// the external command.</param>
/// <param name="elements">A set of elements to which the external application
/// can add elements that are to be highlighted in case of failure or cancellation.</param>
/// <returns>Return the status of the external command.
/// A result of Succeeded means that the API external method functioned as expected.
/// Cancelled can be used to signify that the user cancelled the external operation
/// at some point. Failure should be returned if the application is unable to proceed with
/// the operation.</returns>
public virtual Result Execute(ExternalCommandData commandData
, ref string message, ElementSet elements)
{
try
{
// check user selection
var uiDoc = commandData.Application.ActiveUIDocument;
var doc = uiDoc.Document;
Reference refObj = uiDoc.Selection.PickObject(ObjectType.Element, "Pick a fabrication part to flip.");
var part = doc.GetElement(refObj) as FabricationPart;
if (part == null)
{
message = "The selected element is not a fabrication part.";
return Result.Failed;
}
if (part.CanFlipPart() == false)
{
message = "The selected fabrication part cannot be flipped";
return Result.Failed;
}
using (var trans = new Transaction(doc, "flip part"))
{
trans.Start();
part.Flip();
trans.Commit();
}
return Result.Succeeded;
}
catch (Exception ex)
{
message = ex.Message;
return Result.Failed;
}
}
}
}
@@ -141,7 +141,7 @@ namespace Revit.SDK.Samples.FabricationPartLayout.CS
// centerline length
builder.AppendLine("Centerline Length: " + GetStringFromNumber(doc, part.CenterlineLength, SpecTypeId.Length));
TaskDialog.Show("Fabrication Part [" + part.Id.IntegerValue + "]", builder.ToString());
TaskDialog.Show("Fabrication Part [" + part.Id.ToString() + "]", builder.ToString());
return Result.Succeeded;
}
@@ -174,7 +174,7 @@ namespace Revit.SDK.Samples.FabricationPartLayout.CS
/// <returns>True if the part is fabrication ductwork.</returns>
private bool IsADuct(FabricationPart fabPart)
{
return (fabPart != null && (fabPart.Category.Id.IntegerValue == (int)BuiltInCategory.OST_FabricationDuctwork));
return (fabPart != null && (fabPart.Category.BuiltInCategory == BuiltInCategory.OST_FabricationDuctwork));
}
/// <summary>
@@ -184,7 +184,7 @@ namespace Revit.SDK.Samples.FabricationPartLayout.CS
/// <returns>True if the part is fabrication pipework.</returns>
private bool IsAPipe(FabricationPart fabPart)
{
return (fabPart != null && (fabPart.Category.Id.IntegerValue == (int)BuiltInCategory.OST_FabricationPipework));
return (fabPart != null && (fabPart.Category.BuiltInCategory == BuiltInCategory.OST_FabricationPipework));
}
/// <summary>
@@ -14,6 +14,7 @@
{\pntext\f2\'B7\tab}loading and unloading of item files\par
{\pntext\f2\'B7\tab}exporting fabrication parts to PCF and MAJ\par
{\pntext\f2\'B7\tab}accessing fabrication part mesh geometry.\par
{\pntext\f2\'B7\tab}flip a fabrication part\par
\pard\nowidctlpar\kerning0\f1\par
\b\f0 Classes:\b0 \par
@@ -122,6 +123,11 @@ SaveAsFabricationJob.cs\par
It contains the class ExportToMAJ which inherits from interface IExternalCommand and implements the Execute method. This class shows the user how to export a selection of fabrication parts to a MAJ file.\par
\par
\pard\nowidctlpar FlipPart.cs\par
\pard\nowidctlpar\li360 It contains the class FlipPart which inherits from interface IExternalCommand and implements the Execute method. This class shows the user how to flip a fabrication part to the opposite direction.\par
\par
\pard\nowidctlpar\li360\par
\pard\nowidctlpar\b Description:\b0 \par
@@ -151,7 +157,8 @@ This sample provides the following functionalities.\par
-\tab Load and place additional parts\par
-\tab Unload unused additional parts\par
-\tab Export a selection of fabrication parts to a MAJ file\par
-\tab Access fabrication part mesh geometry.\line\par
-\tab Access fabrication part mesh geometry.\par
-\tab Flip a fabrication part to the opposite direction.\line\par
\pard\nowidctlpar\b Instructions:\cf1\b0 \f1\par
\cf0\f0 Open Revit application.\par
@@ -332,5 +339,11 @@ Expected result: The unused loaded item files will be unloaded from the configur
\par
\tab Expected result: Mesh triangle face geometry will be exported to CSV files.\par
\par
22. Flip Fabrication Part\par
\tab a. Select a fabrication part\par
\tab b. Execute the command\par
\par
\tab Expected result: The fabrication part will to the opposite direction.\par
\par
}