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
+87
View File
@@ -0,0 +1,87 @@
//
// (C) Copyright 2003-2019 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.Text;
using Autodesk.Revit;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
namespace Revit.SDK.Samples.SpotDimension.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)]
[Autodesk.Revit.Attributes.Journaling(Autodesk.Revit.Attributes.JournalingMode.NoCommandData)]
public class Command : 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 Autodesk.Revit.UI.Result Execute(Autodesk.Revit.UI.ExternalCommandData commandData,
ref string message,
ElementSet elements)
{
try
{
Transaction documentTransaction = new Transaction(commandData.Application.ActiveUIDocument.Document, "Document");
documentTransaction.Start();
using (SpotDimensionInfoDlg infoForm = new SpotDimensionInfoDlg(commandData))
{
//Highlight the selected spotdimension
if (infoForm.ShowDialog() == System.Windows.Forms.DialogResult.OK
&& infoForm.SelectedSpotDimension != null)
{
elements.Insert(infoForm.SelectedSpotDimension);
message = "High light the selected SpotDimension";
return Autodesk.Revit.UI.Result.Failed;
}
}
documentTransaction.Commit();
return Autodesk.Revit.UI.Result.Succeeded;
}
catch (Exception ex)
{
// If there are something wrong, give error information and return failed
message = ex.Message;
return Autodesk.Revit.UI.Result.Failed;
}
}
}
}
@@ -0,0 +1,58 @@
//
// (C) Copyright 2003-2019 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.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("SpotDimension")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SpotDimension")]
[assembly: AssemblyCopyright("Copyright © Autodesk, Inc. 2009")]
[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("b254df5b-d939-4fb6-9e9d-66f0d65f4496")]
// 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 Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
@@ -0,0 +1,13 @@
<?xml version="1.0"?>
<RevitAddIns>
<AddIn Type="Command">
<Assembly>SpotDimension.dll</Assembly>
<ClientId>f11032af-f02b-47ad-9e19-330bb9c9988d</ClientId>
<FullClassName>Revit.SDK.Samples.SpotDimension.CS.Command</FullClassName>
<Text>Spot Dimension</Text>
<Description>Get all spot dimensions in all views and show their properties.</Description>
<VisibilityMode>AlwaysVisible</VisibilityMode>
<VendorId>ADSK</VendorId>
<VendorDescription>Autodesk, www.autodesk.com</VendorDescription>
</AddIn>
</RevitAddIns>
@@ -0,0 +1,101 @@
<?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>{4B9E2FC9-BDDA-4434-8BFE-39E13A127049}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SpotDimension</RootNamespace>
<AssemblyName>SpotDimension</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>
<CodeAnalysisRules>
</CodeAnalysisRules>
</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>
<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="SpotDimensionInfoDlg.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="SpotDimensionInfoDlg.Designer.cs">
<DependentUpon>SpotDimensionInfoDlg.cs</DependentUpon>
</Compile>
<Compile Include="SpotDimensionParams.cs" />
<Compile Include="SpotDimensionsData.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="SpotDimensionInfoDlg.resx">
<SubType>Designer</SubType>
<DependentUpon>SpotDimensionInfoDlg.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>
-->
<PropertyGroup>
<PostBuildEvent>set FILEFORSAMPLEREG="$(SolutionDir)..\..\..\..\Regression\API\SDKSamples\UpdateSampleDllForRegression.pl"
if exist %25FILEFORSAMPLEREG%25 perl %25FILEFORSAMPLEREG%25 $(ProjectExt) "$(ProjectPath)" "$(TargetPath)" "$(SolutionDir)"</PostBuildEvent>
</PropertyGroup>
<PropertyGroup>
<ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>None</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
</PropertyGroup>
</Project>
@@ -0,0 +1,193 @@
//
// (C) Copyright 2003-2019 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.
//
namespace Revit.SDK.Samples.SpotDimension.CS
{
/// <summary>
/// spot dimension designer class
/// </summary>
partial class SpotDimensionInfoDlg
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
private SpotDimensionsData m_data;
private SpotDimensionParams m_typeParamsData;
private Autodesk.Revit.DB.SpotDimension m_lastSelectDimention;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.spotDimensionsListView = new System.Windows.Forms.ListView();
this.typeParamsDataGridView = new System.Windows.Forms.DataGridView();
this.viewsComboBox = new System.Windows.Forms.ComboBox();
this.viewLabel = new System.Windows.Forms.Label();
this.okButton = new System.Windows.Forms.Button();
this.cancelButton = new System.Windows.Forms.Button();
this.dimensionsGroupBox = new System.Windows.Forms.GroupBox();
this.infoGroupBox = new System.Windows.Forms.GroupBox();
((System.ComponentModel.ISupportInitialize)(this.typeParamsDataGridView)).BeginInit();
this.dimensionsGroupBox.SuspendLayout();
this.infoGroupBox.SuspendLayout();
this.SuspendLayout();
//
// spotDimensionsListView
//
this.spotDimensionsListView.Location = new System.Drawing.Point(6, 19);
this.spotDimensionsListView.MultiSelect = false;
this.spotDimensionsListView.Name = "spotDimensionsListView";
this.spotDimensionsListView.Size = new System.Drawing.Size(356, 165);
this.spotDimensionsListView.TabIndex = 0;
this.spotDimensionsListView.UseCompatibleStateImageBehavior = false;
this.spotDimensionsListView.View = System.Windows.Forms.View.List;
this.spotDimensionsListView.SelectedIndexChanged += new System.EventHandler(this.spotDimensionsListView_SelectedIndexChanged);
//
// typeParamsDataGridView
//
this.typeParamsDataGridView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
this.typeParamsDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.typeParamsDataGridView.Location = new System.Drawing.Point(6, 19);
this.typeParamsDataGridView.Name = "typeParamsDataGridView";
this.typeParamsDataGridView.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.typeParamsDataGridView.Size = new System.Drawing.Size(356, 183);
this.typeParamsDataGridView.TabIndex = 2;
//
// viewsComboBox
//
this.viewsComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.viewsComboBox.FormattingEnabled = true;
this.viewsComboBox.Location = new System.Drawing.Point(59, 16);
this.viewsComboBox.Name = "viewsComboBox";
this.viewsComboBox.Size = new System.Drawing.Size(324, 21);
this.viewsComboBox.TabIndex = 3;
this.viewsComboBox.SelectedIndexChanged += new System.EventHandler(this.viewsComboBox_SelectedIndexChanged);
//
// viewLabel
//
this.viewLabel.AutoSize = true;
this.viewLabel.Location = new System.Drawing.Point(12, 19);
this.viewLabel.Name = "viewLabel";
this.viewLabel.Size = new System.Drawing.Size(30, 13);
this.viewLabel.TabIndex = 4;
this.viewLabel.Text = "View";
//
// okButton
//
this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
this.okButton.Location = new System.Drawing.Point(227, 457);
this.okButton.Name = "okButton";
this.okButton.Size = new System.Drawing.Size(75, 23);
this.okButton.TabIndex = 5;
this.okButton.Text = "&Ok";
this.okButton.UseVisualStyleBackColor = true;
//
// cancelButton
//
this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.cancelButton.Location = new System.Drawing.Point(308, 457);
this.cancelButton.Name = "cancelButton";
this.cancelButton.Size = new System.Drawing.Size(75, 23);
this.cancelButton.TabIndex = 6;
this.cancelButton.Text = "&Cancel";
this.cancelButton.UseVisualStyleBackColor = true;
//
// dimensionsGroupBox
//
this.dimensionsGroupBox.Controls.Add(this.spotDimensionsListView);
this.dimensionsGroupBox.Location = new System.Drawing.Point(15, 47);
this.dimensionsGroupBox.Name = "dimensionsGroupBox";
this.dimensionsGroupBox.Size = new System.Drawing.Size(368, 190);
this.dimensionsGroupBox.TabIndex = 7;
this.dimensionsGroupBox.TabStop = false;
this.dimensionsGroupBox.Text = "SpotDimensions";
//
// infoGroupBox
//
this.infoGroupBox.Controls.Add(this.typeParamsDataGridView);
this.infoGroupBox.Location = new System.Drawing.Point(15, 243);
this.infoGroupBox.Name = "infoGroupBox";
this.infoGroupBox.Size = new System.Drawing.Size(368, 208);
this.infoGroupBox.TabIndex = 8;
this.infoGroupBox.TabStop = false;
this.infoGroupBox.Text = "Parameters Information";
//
// SpotDimensionInfoDlg
//
this.AcceptButton = this.okButton;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.cancelButton;
this.ClientSize = new System.Drawing.Size(395, 492);
this.Controls.Add(this.infoGroupBox);
this.Controls.Add(this.dimensionsGroupBox);
this.Controls.Add(this.cancelButton);
this.Controls.Add(this.okButton);
this.Controls.Add(this.viewLabel);
this.Controls.Add(this.viewsComboBox);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "SpotDimensionInfoDlg";
this.ShowInTaskbar = false;
this.Text = "Informations of SpotDimension";
((System.ComponentModel.ISupportInitialize)(this.typeParamsDataGridView)).EndInit();
this.dimensionsGroupBox.ResumeLayout(false);
this.infoGroupBox.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.ListView spotDimensionsListView;
private System.Windows.Forms.DataGridView typeParamsDataGridView;
private System.Windows.Forms.ComboBox viewsComboBox;
private System.Windows.Forms.Label viewLabel;
private System.Windows.Forms.Button okButton;
private System.Windows.Forms.Button cancelButton;
private System.Windows.Forms.GroupBox dimensionsGroupBox;
private System.Windows.Forms.GroupBox infoGroupBox;
}
}
@@ -0,0 +1,156 @@
//
// (C) Copyright 2003-2019 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.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Autodesk.Revit;
namespace Revit.SDK.Samples.SpotDimension.CS
{
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
/// <summary>
/// spot dimension form to display information
/// </summary>
public partial class SpotDimensionInfoDlg : System.Windows.Forms.Form
{
/// <summary>
/// Get the last selected spot dimension
/// </summary>
public Autodesk.Revit.DB.SpotDimension SelectedSpotDimension
{
get
{
return m_lastSelectDimention;
}
}
/// <summary>
/// Default constructor
/// </summary>
public SpotDimensionInfoDlg()
{
InitializeComponent();
}
/// <summary>
/// Overload constructor
/// </summary>
/// <param name="data"></param>
public SpotDimensionInfoDlg(ExternalCommandData data)
{
this.m_data = new SpotDimensionsData(data);
this.m_typeParamsData = new SpotDimensionParams(data.Application.ActiveUIDocument.Document);
InitializeComponent();
InitializeCustomComponent();
}
/// <summary>
/// Initialize custom component
/// </summary>
private void InitializeCustomComponent()
{
this.viewsComboBox.DataSource = this.m_data.Views;
if (this.viewsComboBox.Items.Count > 0)
{
this.viewsComboBox.SelectedIndex = 0;
}
this.typeParamsDataGridView.ScrollBars = ScrollBars.Both;
this.typeParamsDataGridView.AllowUserToResizeColumns = false;
this.typeParamsDataGridView.ColumnHeadersVisible = true;
this.typeParamsDataGridView.RowHeadersVisible = false;
this.typeParamsDataGridView.AllowUserToResizeRows = false;
this.typeParamsDataGridView.AllowUserToOrderColumns = false;
this.typeParamsDataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.DisplayedCells;
}
/// <summary>
/// Display all the spot dimensions in the selected view
/// </summary>
/// <param name="viewName"></param>
private void DisplaySpotDimensionInfos(string viewName)
{
this.spotDimensionsListView.Items.Clear();
//add SpotDimensions to the listview
foreach (SpotDimension tmpSpotDimension in m_data.SpotDimensions)
{
if (tmpSpotDimension.View.Name == viewName)
{
//create a list view Item
ListViewItem tmpItem = new ListViewItem(tmpSpotDimension.Id.IntegerValue.ToString());
tmpItem.Tag = tmpSpotDimension;
//add the item to the listview
this.spotDimensionsListView.Items.Add(tmpItem);
}
}
}
/// <summary>
/// When selected another spot dimension then update the DataGridView.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void spotDimensionsListView_SelectedIndexChanged(object sender, EventArgs e)
{
if (this.spotDimensionsListView.FocusedItem != null)
{
m_lastSelectDimention = this.spotDimensionsListView.FocusedItem.Tag as SpotDimension;
this.typeParamsDataGridView.DataSource
= this.m_typeParamsData.GetParameterTable(m_lastSelectDimention);
this.typeParamsDataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells);
if (this.typeParamsDataGridView.Columns[0].Width + this.typeParamsDataGridView.Columns[1].Width < this.typeParamsDataGridView.Width)
{
this.typeParamsDataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
this.typeParamsDataGridView.AutoResizeColumns();
}
}
}
/// <summary>
/// When selected view changed, then update the list box to show the spot dimensions in that view.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void viewsComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
string selectViewName = this.viewsComboBox.SelectedItem as string;
if (selectViewName != null)
{
DisplaySpotDimensionInfos(selectViewName);
}
}
}
}
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
@@ -0,0 +1,304 @@
//
// (C) Copyright 2003-2019 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.Data;
using System.Text;
using System.Collections.Generic;
using System.Diagnostics;
using Autodesk.Revit;
using Autodesk.Revit.DB;
namespace Revit.SDK.Samples.SpotDimension.CS
{
/// <summary>
/// this class is used to get some information
/// of SpotDimension's Parameters
/// </summary>
public class SpotDimensionParams
{
const double ToFractionalInches = 0.08333333; //const number to convert number to FractionalInches
static List<string> s_elevationOrigin = new List<string>(); //list store information about Elevation origin
static List<string> s_textOrientation = new List<string>(); //list store information about Text Orientation
static List<string> s_indicator = new List<string>(); //list store information about s_indicator
static List<string> s_topBottomValue = new List<string>(); //list store information about Top and Bottom Value
static List<string> s_textBackground = new List<string>(); //list store information about Text background
Document m_document; //a reference to Revit's document
/// <summary>
/// static constructor used to initialize lists
/// </summary>
static SpotDimensionParams()
{
//add string elements to lists
s_elevationOrigin.Add("Project");
s_elevationOrigin.Add("Shared");
s_elevationOrigin.Add("Relative");
s_textOrientation.Add("Horizontal Above");
s_textOrientation.Add("Horizontal Below");
s_indicator.Add("Prefix");
s_indicator.Add("Suffix");
s_topBottomValue.Add("None");
s_topBottomValue.Add("North / South");
s_topBottomValue.Add("East / West");
s_textBackground.Add("Opaque");
s_textBackground.Add("Transparent");
}
/// <summary>
/// a constructor of class SpotDimensionParams
/// </summary>
/// <param name="document">external command document of Revit</param>
public SpotDimensionParams(Document document)
{
m_document = document;
}
/// <summary>
/// get a datatable contains parameters'information of SpotDimension
/// here, almost only get Type Parameters of SpotDimension
/// </summary>
/// <param name="spotDimension">the SpotDimension need to be dealt with</param>
/// <returns>a DataTable store Parameter information</returns>
public DataTable GetParameterTable(Autodesk.Revit.DB.SpotDimension spotDimension)
{
try
{
//check whether is null
if (null == spotDimension)
{
return null;
}
//create an empty datatable
DataTable parameterTable = CreateTable();
//get DimensionType
Autodesk.Revit.DB.DimensionType dimensionType = spotDimension.DimensionType;
//begin to get Parameters and add them to a DataTable
Parameter temporaryParam = null;
string temporaryValue = "";
#region Get all SpotDimension element parameters
//string formatter
string formatter = "#0.000";
//Property Category of SpotDimension
AddDataRow("Category", spotDimension.Category.Name, parameterTable);
//Leader Arrowhead
temporaryParam =
dimensionType.get_Parameter(BuiltInParameter.SPOT_ELEV_LEADER_ARROWHEAD);
Autodesk.Revit.DB.ElementId elementId = temporaryParam.AsElementId();
//if not found that element, add string "None" to DataTable
if (-1 == elementId.IntegerValue)
{
temporaryValue = "None";
}
else
{
temporaryValue = m_document.GetElement(elementId).Name;
}
AddDataRow(temporaryParam.Definition.Name, temporaryValue, parameterTable);
//Leader Line Weight
temporaryParam = dimensionType.get_Parameter(BuiltInParameter.SPOT_ELEV_LINE_PEN);
temporaryValue = temporaryParam.AsInteger().ToString();
AddDataRow(temporaryParam.Definition.Name, temporaryValue, parameterTable);
//Leader Arrowhead Line Weight
temporaryParam =
dimensionType.get_Parameter(BuiltInParameter.SPOT_ELEV_TICK_MARK_PEN);
temporaryValue = temporaryParam.AsInteger().ToString();
AddDataRow(temporaryParam.Definition.Name, temporaryValue, parameterTable);
//Symbol
temporaryParam = dimensionType.get_Parameter(BuiltInParameter.SPOT_ELEV_SYMBOL);
elementId = temporaryParam.AsElementId();
//if not found that element, add string "None" to DataTable
if (-1 == elementId.IntegerValue)
{
temporaryValue = "None";
}
else
{
temporaryValue = m_document.GetElement(elementId).Name;
}
AddDataRow(temporaryParam.Definition.Name, temporaryValue, parameterTable);
//Text Size
temporaryParam = dimensionType.get_Parameter(BuiltInParameter.TEXT_SIZE);
temporaryValue =
(temporaryParam.AsDouble() / ToFractionalInches).ToString(formatter) + "''";
AddDataRow(temporaryParam.Definition.Name, temporaryValue, parameterTable);
//Text Offset from Leader
temporaryParam =
dimensionType.get_Parameter(BuiltInParameter.SPOT_TEXT_FROM_LEADER);
temporaryValue =
(temporaryParam.AsDouble() / ToFractionalInches).ToString(formatter) + "''";
AddDataRow(temporaryParam.Definition.Name, temporaryValue, parameterTable);
//Text Offset from Symbol
temporaryParam =
dimensionType.get_Parameter(BuiltInParameter.SPOT_ELEV_TEXT_HORIZ_OFFSET);
temporaryValue =
(temporaryParam.AsDouble() / ToFractionalInches).ToString(formatter) + "''";
AddDataRow(temporaryParam.Definition.Name, temporaryValue, parameterTable);
//for Spot Coordinates, add some other Parameters
if ("Spot Coordinates" == spotDimension.Category.Name)
{
//Coordinate Origin
temporaryParam =
dimensionType.get_Parameter(BuiltInParameter.SPOT_COORDINATE_BASE);
temporaryValue = temporaryParam.AsInteger().ToString();
AddDataRow(temporaryParam.Definition.Name, temporaryValue, parameterTable);
//Top Value
temporaryParam =
dimensionType.get_Parameter(BuiltInParameter.SPOT_ELEV_TOP_VALUE);
temporaryValue = s_topBottomValue[temporaryParam.AsInteger()];
AddDataRow(temporaryParam.Definition.Name, temporaryValue, parameterTable);
//Bottom Value
temporaryParam =
dimensionType.get_Parameter(BuiltInParameter.SPOT_ELEV_BOT_VALUE);
temporaryValue = s_topBottomValue[temporaryParam.AsInteger()];
AddDataRow(temporaryParam.Definition.Name, temporaryValue, parameterTable);
//North / South s_indicator
temporaryParam =
dimensionType.get_Parameter(BuiltInParameter.SPOT_ELEV_IND_NS);
temporaryValue = temporaryParam.AsString();
AddDataRow(temporaryParam.Definition.Name, temporaryValue, parameterTable);
//East / West s_indicator
temporaryParam =
dimensionType.get_Parameter(BuiltInParameter.SPOT_ELEV_IND_EW);
temporaryValue = temporaryParam.AsString();
AddDataRow(temporaryParam.Definition.Name, temporaryValue, parameterTable);
}
//for Spot Elevation, add some other Parameters
else
{
//Instance Parameter----Value
temporaryParam =
spotDimension.get_Parameter(BuiltInParameter.DIM_VALUE_LENGTH);
temporaryValue = temporaryParam.AsDouble().ToString(formatter) + "'";
AddDataRow(temporaryParam.Definition.Name, temporaryValue, parameterTable);
//Elevation Origin
temporaryParam = dimensionType.get_Parameter(BuiltInParameter.SPOT_ELEV_BASE);
temporaryValue = s_elevationOrigin[temporaryParam.AsInteger()];
AddDataRow(temporaryParam.Definition.Name, temporaryValue, parameterTable);
//Elevation s_indicator
temporaryParam =
dimensionType.get_Parameter(BuiltInParameter.SPOT_ELEV_IND_ELEVATION);
temporaryValue = temporaryParam.AsString();
AddDataRow(temporaryParam.Definition.Name, temporaryValue, parameterTable);
}
//Text Orientation
temporaryParam =
dimensionType.get_Parameter(BuiltInParameter.SPOT_ELEV_TEXT_ORIENTATION);
temporaryValue = s_textOrientation[temporaryParam.AsInteger()];
AddDataRow(temporaryParam.Definition.Name, temporaryValue, parameterTable);
//s_indicator as Prefix / Suffix
temporaryParam = dimensionType.get_Parameter(BuiltInParameter.SPOT_ELEV_IND_TYPE);
temporaryValue = s_indicator[temporaryParam.AsInteger()];
AddDataRow(temporaryParam.Definition.Name, temporaryValue, parameterTable);
//Text Font
temporaryParam = dimensionType.get_Parameter(BuiltInParameter.TEXT_FONT);
temporaryValue = temporaryParam.AsString();
AddDataRow(temporaryParam.Definition.Name, temporaryValue, parameterTable);
//Text Background
temporaryParam = dimensionType.get_Parameter(BuiltInParameter.DIM_TEXT_BACKGROUND);
temporaryValue = s_textBackground[temporaryParam.AsInteger()];
AddDataRow(temporaryParam.Definition.Name, temporaryValue, parameterTable);
#endregion
return parameterTable;
}
catch (Exception ex)
{
Trace.WriteLine(ex.Message, "A error in Function 'GetParameterTable':");
return null;
}
}
/// <summary>
/// Create an empty table with parameter's name column and value column
/// </summary>
/// <returns>a DataTable be initialized</returns>
private DataTable CreateTable()
{
// Create a new DataTable.
DataTable propDataTable = new DataTable("ParameterTable");
// Create parameter column and add to the DataTable.
DataColumn paraDataColumn = new DataColumn();
paraDataColumn.DataType = System.Type.GetType("System.String");
paraDataColumn.ColumnName = "Parameter";
paraDataColumn.Caption = "Parameter";
paraDataColumn.ReadOnly = true;
// Add the column to the DataColumnCollection.
propDataTable.Columns.Add(paraDataColumn);
// Create value column and add to the DataTable.
DataColumn valueDataColumn = new DataColumn();
valueDataColumn.DataType = System.Type.GetType("System.String");
valueDataColumn.ColumnName = "Value";
valueDataColumn.Caption = "Value";
valueDataColumn.ReadOnly = true;
propDataTable.Columns.Add(valueDataColumn);
return propDataTable;
}
/// <summary>
/// add one row to datatable
/// </summary>
/// <param name="parameterName">name of parameter</param>
/// <param name="Value">value of parameter</param>
/// <param name="parameterTable">datatable to be added row</param>
private void AddDataRow(string parameterName, string Value, DataTable parameterTable)
{
DataRow newRow = parameterTable.NewRow();
newRow["Parameter"] = parameterName;
newRow["Value"] = Value;
parameterTable.Rows.Add(newRow);
}
}
}
@@ -0,0 +1,107 @@
//
// (C) Copyright 2003-2019 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.Text;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Autodesk.Revit;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.ApplicationServices;
namespace Revit.SDK.Samples.SpotDimension.CS
{
/// <summary>
/// Store all the views and spot dimensions in Revit.
/// </summary>
public class SpotDimensionsData
{
UIApplication m_revit; // Store the reference of the application in Revit
List<string> m_views = new List<string>();
List<Autodesk.Revit.DB.SpotDimension> m_spotDimensions = new List<Autodesk.Revit.DB.SpotDimension>(); //a list to store all SpotDimensions in the project
/// <summary>
/// a list of all the SpotDimensions in the project
/// </summary>
public ReadOnlyCollection<Autodesk.Revit.DB.SpotDimension> SpotDimensions
{
get
{
return new ReadOnlyCollection<Autodesk.Revit.DB.SpotDimension>(m_spotDimensions);
}
}
/// <summary>
/// a list of all the views that have SpotDimentions in the project
/// </summary>
public ReadOnlyCollection<string> Views
{
get
{
return new ReadOnlyCollection<string>(m_views);
}
}
/// <summary>
/// Constructor
/// </summary>
/// <param name="commandData"></param>
public SpotDimensionsData(ExternalCommandData commandData)
{
m_revit = commandData.Application;
GetSpotDimensions();
}
/// <summary>
/// try to find all the SpotDimensions and add them to the list
/// </summary>
private void GetSpotDimensions()
{
//get the active document
Document document = m_revit.ActiveUIDocument.Document;
FilteredElementIterator elementIterator = (new FilteredElementCollector(document)).OfClass(typeof(Autodesk.Revit.DB.SpotDimension)).GetElementIterator();
elementIterator.Reset();
while (elementIterator.MoveNext())
{
//find all the SpotDimensions and views
Autodesk.Revit.DB.SpotDimension tmpSpotDimension = elementIterator.Current as Autodesk.Revit.DB.SpotDimension;
if (null != tmpSpotDimension)
{
m_spotDimensions.Add(tmpSpotDimension);
if (m_views.Contains(tmpSpotDimension.View.Name) == false)
{
m_views.Add(tmpSpotDimension.View.Name);
}
}
}
}
}
}