added Revit 2022 SDK minus except *rvt and *rfa

This commit is contained in:
Jeremy Tammik
2021-04-20 11:36:21 +02:00
parent 1133a82dc5
commit 7e327986e8
3034 changed files with 1245318 additions and 0 deletions
@@ -0,0 +1,421 @@
//
// (C) Copyright 2003-2021 by Autodesk, Inc. All rights reserved.
//
// 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 ITS 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.Linq;
using System.Collections.Generic;
using Autodesk;
using Autodesk.Revit;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.ApplicationServices;
namespace Revit.SDK.Samples.ExportPDFSettingsSample.CS
{
/// <summary>
/// ExternalApplication for ExportPDFSettings manipulation through Revit API. ExportPDFSettings is the element to store PDFExportOptions in document.
/// This sample contains:
/// - Create ExportPDFSettings
/// - Modify ExportPDFSettings
/// - Add naming rule for ExportPDFSettings
/// - Modify naming rule for ExportPDFSettings
/// - Delete naming rule for ExportPDFSettings
/// </summary>
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
[Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)]
public class ExportPDFSettingsSampleApplication : IExternalApplication
{
#region IExternalApplication Members
/// <summary>
/// Implements the OnShutdown event
/// </summary>
/// <param name="application"></param>
/// <returns></returns>
public Result OnShutdown(UIControlledApplication application)
{
return Result.Succeeded;
}
/// <summary>
/// Implements the OnStartup event
/// </summary>
/// <param name="application"></param>
/// <returns></returns>
public Result OnStartup(UIControlledApplication application)
{
try
{
// Create user interface for ExportPDFSettings manipulation
RibbonPanel panel = application.CreateRibbonPanel("ExportPDFSettings testing");
System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
panel.AddItem(new PushButtonData("CreateExportPDFSettingsInstance",
"Create ExportPDFSettings Instance",
assembly.Location,
"Revit.SDK.Samples.ExportPDFSettingsSample.CS.CreateExportPDFSettingsCommand"));
panel.AddSeparator();
panel.AddItem(new PushButtonData("ModifyExportPDFSettingsInstance",
"Modify ExportPDFSettings Instance",
assembly.Location,
"Revit.SDK.Samples.ExportPDFSettingsSample.CS.ModifyExportPDFSettingsCommand"));
panel.AddSeparator();
panel.AddItem(new PushButtonData("AddNamingRule",
"Add Naming Rule",
assembly.Location,
"Revit.SDK.Samples.ExportPDFSettingsSample.CS.AddNamingRuleCommand"));
panel.AddSeparator();
panel.AddItem(new PushButtonData("ModifyNamingRule",
"Mofidy Naming Rule",
assembly.Location,
"Revit.SDK.Samples.ExportPDFSettingsSample.CS.MofidyNamingRuleCommand"));
panel.AddSeparator();
panel.AddItem(new PushButtonData("DeleteNamingRule",
"Delete Naming Rule",
assembly.Location,
"Revit.SDK.Samples.ExportPDFSettingsSample.CS.DeleteNamingRuleCommand"));
}
catch (Exception e)
{
TaskDialog.Show("Exception from OnStartup", e.ToString());
}
return Result.Succeeded;
}
#endregion
}
/// <summary>
/// ExternalCommand to create an ExportPDFSettings instance.
/// </summary>
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
public class CreateExportPDFSettingsCommand : IExternalCommand
{
#region IExternalCommand Members
/// <summary>
/// The implementation for IExternalCommand.Execute()
/// </summary>
/// <param name="commandData">The Revit command data.</param>
/// <param name="message">The error message (ignored).</param>
/// <param name="elements">The elements to display in the failure dialog (ignored).</param>
/// <returns>Result.Succeeded</returns>
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
Document doc = commandData.Application.ActiveUIDocument.Document;
Transaction trans = new Transaction(doc, "Create ExportPDFSettings");
trans.Start();
try
{
PDFExportOptions options = new PDFExportOptions();
string name = "sample";
ExportPDFSettings settings = ExportPDFSettings.Create(doc, name, options);
}
catch (Exception ex)
{
message = ex.ToString();
trans.RollBack();
return Result.Failed;
}
trans.Commit();
return Result.Succeeded;
}
#endregion
}
/// <summary>
/// ExternalCommand to modify an ExportPDFSettings instance.
/// </summary>
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
public class ModifyExportPDFSettingsCommand : IExternalCommand
{
#region IExternalCommand Members
/// <summary>
/// The implementation for IExternalCommand.Execute()
/// </summary>
/// <param name="commandData">The Revit command data.</param>
/// <param name="message">The error message (ignored).</param>
/// <param name="elements">The elements to display in the failure dialog (ignored).</param>
/// <returns>Result.Succeeded</returns>
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
Document doc = commandData.Application.ActiveUIDocument.Document;
Transaction trans = new Transaction(doc, "Modify ExportPDFSettings");
trans.Start();
try
{
ExportPDFSettings settings = ExportPDFSettings.FindByName(doc, "sample");
if (settings == null)
{
message = "Cannot find sample settings";
trans.RollBack();
return Result.Failed;
}
PDFExportOptions options = settings.GetOptions();
options.PaperFormat = ExportPaperFormat.ISO_A4; // Change paper format
options.HideCropBoundaries = false; // Change hide crop boundaries
options.Combine = false; // Change name into the pattern of naming rule
settings.SetOptions(options); // Activate changes
}
catch (Exception ex)
{
message = ex.ToString();
trans.RollBack();
return Result.Failed;
}
trans.Commit();
return Result.Succeeded;
}
#endregion
}
/// <summary>
/// ExternalCommand to add a naming rule to ExportPDFSettings instance.
/// </summary>
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
public class AddNamingRuleCommand : IExternalCommand
{
#region IExternalCommand Members
/// <summary>
/// The implementation for IExternalCommand.Execute()
/// </summary>
/// <param name="commandData">The Revit command data.</param>
/// <param name="message">The error message (ignored).</param>
/// <param name="elements">The elements to display in the failure dialog (ignored).</param>
/// <returns>Result.Succeeded</returns>
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
Document doc = commandData.Application.ActiveUIDocument.Document;
Transaction trans = new Transaction(doc, "Add a naming rule");
trans.Start();
try
{
ExportPDFSettings settings = ExportPDFSettings.FindByName(doc, "sample");
if (settings == null)
{
message = "Cannot find sample settings";
trans.RollBack();
return Result.Failed;
}
PDFExportOptions options = settings.GetOptions();
// Naming rule remains the same in silence if exporting is combined
if (options.Combine)
{
message = "Exporting is combined. To change naming rule you need to set exporting not combined.";
trans.RollBack();
return Result.Failed;
}
// Get naming rule
IList<TableCellCombinedParameterData> namingRule = options.GetNamingRule();
// Add naming parameter Sheets-Approved-By to naming rule
BuiltInParameter param = BuiltInParameter.SHEET_APPROVED_BY;
ElementId categoryId = Category.GetCategory(doc, BuiltInCategory.OST_Sheets).Id;
ElementId paramId = new ElementId(param);
TableCellCombinedParameterData itemSheetApprovedBy = TableCellCombinedParameterData.Create();
itemSheetApprovedBy.CategoryId = categoryId;
itemSheetApprovedBy.ParamId = paramId;
itemSheetApprovedBy.Prefix = "-"; // You can also add prefix/suffix
itemSheetApprovedBy.Separator = "-";
itemSheetApprovedBy.SampleValue = param.ToString();
namingRule.Add(itemSheetApprovedBy);
// Don't forget to set naming rule for options
options.SetNamingRule(namingRule);
// And save the options for settings
// Note that naming rule won't be changed if exporting is combined, see the comments of PDFExportOptions.SetOptions
settings.SetOptions(options);
}
catch (Exception ex)
{
message = ex.ToString();
trans.RollBack();
return Result.Failed;
}
trans.Commit();
return Result.Succeeded;
}
#endregion
}
/// <summary>
/// ExternalCommand to modify a naming rule from ExportPDFSettings instance.
/// </summary>
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
public class MofidyNamingRuleCommand : IExternalCommand
{
#region IExternalCommand Members
/// <summary>
/// The implementation for IExternalCommand.Execute()
/// </summary>
/// <param name="commandData">The Revit command data.</param>
/// <param name="message">The error message (ignored).</param>
/// <param name="elements">The elements to display in the failure dialog (ignored).</param>
/// <returns>Result.Succeeded</returns>
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
Document doc = commandData.Application.ActiveUIDocument.Document;
Transaction trans = new Transaction(doc, "Modify a naming rule");
trans.Start();
try
{
ExportPDFSettings settings = ExportPDFSettings.FindByName(doc, "sample");
if (settings == null)
{
message = "Cannot find sample settings";
trans.RollBack();
return Result.Failed;
}
PDFExportOptions options = settings.GetOptions();
// Naming rule remains the same in silence if exporting is combined
if (options.Combine)
{
message = "Exporting is combined. To change naming rule you need to set exporting not combined.";
trans.RollBack();
return Result.Failed;
}
// Get naming rule
IList<TableCellCombinedParameterData> namingRule = options.GetNamingRule();
// Find SHEET_APPROVED_BY rule
BuiltInParameter param = BuiltInParameter.SHEET_APPROVED_BY;
ElementId categoryId = Category.GetCategory(doc, BuiltInCategory.OST_Sheets).Id;
ElementId paramId = new ElementId(param);
TableCellCombinedParameterData rule = namingRule.SingleOrDefault(r => (r.CategoryId == categoryId && r.ParamId == paramId));
if (rule == null)
{
message = "No such rule in naming rule";
trans.RollBack();
return Result.Failed;
}
// Mofidy rule
rule.SampleValue = "Modify my sample value";
namingRule = namingRule.OrderBy(data => data.SampleValue).ToList(); // The order of rules is defined by the naming rule list
options.SetNamingRule(namingRule);
// Note that naming rule won't be changed if exporting is combined, see the comments of PDFExportOptions.SetOptions
settings.SetOptions(options);
}
catch (Exception ex)
{
message = ex.ToString();
trans.RollBack();
return Result.Failed;
}
trans.Commit();
return Result.Succeeded;
}
#endregion
}
/// <summary>
/// ExternalCommand to delete a naming rule from ExportPDFSettings instance.
/// </summary>
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
public class DeleteNamingRuleCommand : IExternalCommand
{
#region IExternalCommand Members
/// <summary>
/// The implementation for IExternalCommand.Execute()
/// </summary>
/// <param name="commandData">The Revit command data.</param>
/// <param name="message">The error message (ignored).</param>
/// <param name="elements">The elements to display in the failure dialog (ignored).</param>
/// <returns>Result.Succeeded</returns>
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
Document doc = commandData.Application.ActiveUIDocument.Document;
Transaction trans = new Transaction(doc, "Delete a naming rule");
trans.Start();
try
{
ExportPDFSettings settings = ExportPDFSettings.FindByName(doc, "sample");
if (settings == null)
{
message = "Cannot find sample settings";
trans.RollBack();
return Result.Failed;
}
PDFExportOptions options = settings.GetOptions();
// Naming rule remains the same in silence if exporting is combined
if (options.Combine)
{
message = "Exporting is combined. To change naming rule you need to set exporting not combined.";
trans.RollBack();
return Result.Failed;
}
// Get naming rule
IList<TableCellCombinedParameterData> namingRule = options.GetNamingRule();
// Find SHEET_APPROVED_BY rule
BuiltInParameter param = BuiltInParameter.SHEET_APPROVED_BY;
ElementId categoryId = Category.GetCategory(doc, BuiltInCategory.OST_Sheets).Id;
ElementId paramId = new ElementId(param);
TableCellCombinedParameterData rule = namingRule.SingleOrDefault(r => (r.CategoryId == categoryId && r.ParamId == paramId));
// Delete rule
namingRule.Remove(rule);
options.SetNamingRule(namingRule);
// Note that naming rule won't be changed if exporting is combined, see the comments of PDFExportOptions.SetOptions
settings.SetOptions(options);
}
catch (Exception ex)
{
message = ex.ToString();
trans.RollBack();
return Result.Failed;
}
trans.Commit();
return Result.Succeeded;
}
#endregion
}
}
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<RevitAddIns>
<AddIn Type="Application">
<Name>ExportPDFSettingsSample</Name>
<Assembly>ExportPDFSettingsSample.dll</Assembly>
<ClientId>4e823ca0-fd4d-4266-a744-4b68bab91a55</ClientId>
<FullClassName>Revit.SDK.Samples.ExportPDFSettingsSample.CS.ExportPDFSettingsSampleApplication</FullClassName>
<VendorId>ADSK</VendorId>
<VendorDescription>Autodesk, www.autodesk.com</VendorDescription>
</AddIn>
<AddIn Type="Command">
<Assembly>ExportPDFSettingsSample.dll</Assembly>
<ClientId>029A6F10-1BD9-42F6-80F7-D18512399F99</ClientId>
<FullClassName>Revit.SDK.Samples.ExportPDFSettingsSample.CS.CreateExportPDFSettingsCommand</FullClassName>
<Text>Create ExportPDFSettings Instance</Text>
<Description>Create ExportPDFSettings Instance</Description>
<VisibilityMode>AlwaysVisible</VisibilityMode>
<VendorId>ADSK</VendorId>
<VendorDescription>Autodesk, www.autodesk.com</VendorDescription>
</AddIn>
<AddIn Type="Command">
<Assembly>ExportPDFSettingsSample.dll</Assembly>
<ClientId>6A823255-D9E7-4583-9A58-910FC77D5B44</ClientId>
<FullClassName>Revit.SDK.Samples.ExportPDFSettingsSample.CS.ModifyExportPDFSettingsCommand</FullClassName>
<Text>Modify ExportPDFSettings Instance</Text>
<Description>Modify ExportPDFSettings Instance</Description>
<VisibilityMode>AlwaysVisible</VisibilityMode>
<VendorId>ADSK</VendorId>
<VendorDescription>Autodesk, www.autodesk.com</VendorDescription>
</AddIn>
<AddIn Type="Command">
<Assembly>ExportPDFSettingsSample.dll</Assembly>
<ClientId>076599A2-0535-4F07-83F7-BD7F35D8BCFE</ClientId>
<FullClassName>Revit.SDK.Samples.ExportPDFSettingsSample.CS.AddNamingRuleCommand</FullClassName>
<Text>Add Naming Rule</Text>
<Description>Add Naming Rule for ExportPDFSettings</Description>
<VisibilityMode>AlwaysVisible</VisibilityMode>
<VendorId>ADSK</VendorId>
<VendorDescription>Autodesk, www.autodesk.com</VendorDescription>
</AddIn>
<AddIn Type="Command">
<Assembly>ExportPDFSettingsSample.dll</Assembly>
<ClientId>66E62476-5DA9-4DCC-B77C-E6F4176FCA94</ClientId>
<FullClassName>Revit.SDK.Samples.ExportPDFSettingsSample.CS.MofidyNamingRuleCommand</FullClassName>
<Text>Modify Naming Rule</Text>
<Description>Modify Naming Rule for ExportPDFSettings</Description>
<VisibilityMode>AlwaysVisible</VisibilityMode>
<VendorId>ADSK</VendorId>
<VendorDescription>Autodesk, www.autodesk.com</VendorDescription>
</AddIn>
<AddIn Type="Command">
<Assembly>ExportPDFSettingsSample.dll</Assembly>
<ClientId>D6083018-8DE3-4025-A914-E7B813D6632F</ClientId>
<FullClassName>Revit.SDK.Samples.ExportPDFSettingsSample.CS.DeleteNamingRuleCommand</FullClassName>
<Text>Delete Naming Rule</Text>
<Description>Delete Naming Rule for ExportPDFSettings</Description>
<VisibilityMode>AlwaysVisible</VisibilityMode>
<VendorId>ADSK</VendorId>
<VendorDescription>Autodesk, www.autodesk.com</VendorDescription>
</AddIn>
</RevitAddIns>
@@ -0,0 +1,90 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{2A3251E8-790B-45D5-A680-4AE8E794FA7A}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ExportPDFSettingsSample</RootNamespace>
<AssemblyName>ExportPDFSettingsSample</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</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>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<DocumentationFile>bin\Debug\ExportPDFSettingsSample.XML</DocumentationFile>
</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>
<DocumentationFile>bin\Release\ExportPDFSettingsSample.XML</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x64</PlatformTarget>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<DocumentationFile>bin\Debug\ExportPDFSettingsSample.XML</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x64</PlatformTarget>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<DocumentationFile>bin\Release\ExportPDFSettingsSample.XML</DocumentationFile>
</PropertyGroup>
<PropertyGroup>
<RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="System.Core">
<RequiredTargetFramework>4.7</RequiredTargetFramework>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Application.cs" />
<Compile Include="Properties\AssemblyInfo.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.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<PropertyGroup>
<PostBuildEvent>set FILEFORSAMPLEREG="$(SolutionDir)..\..\..\..\Regression\API\SDKSamples\UpdateSampleDllForRegression.pl"
if exist %25FILEFORSAMPLEREG%25 perl %25FILEFORSAMPLEREG%25 $(ProjectExt) "$(ProjectPath)" "$(TargetPath)" "$(SolutionDir)"</PostBuildEvent>
</PropertyGroup>
</Project>
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ExportPDFSettingsSample")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ExportPDFSettingsSample")]
[assembly: AssemblyCopyright("Copyright © Autodesk, Inc. 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("2a3251e8-790b-45d5-a680-4ae8e794fa7a")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
File diff suppressed because it is too large Load Diff