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,81 @@
//
// (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;
//
// 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("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("Copyright © Autodesk, Inc. 2009")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
//
// 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.*")]
//
// In order to sign your assembly you must specify a key to use. Refer to the
// Microsoft .NET Framework documentation for more information on assembly signing.
//
// Use the attributes below to control which key is used for signing.
//
// Notes:
// (*) If no key is specified, the assembly is not signed.
// (*) KeyName refers to a key that has been installed in the Crypto Service
// Provider (CSP) on your machine. KeyFile refers to a file which contains
// a key.
// (*) If the KeyFile and the KeyName values are both specified, the
// following processing occurs:
// (1) If the KeyName can be found in the CSP, that key is used.
// (2) If the KeyName does not exist and the KeyFile does exist, the key
// in the KeyFile is installed into the CSP and used.
// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
// When specifying the KeyFile, the location of the KeyFile should be
// relative to the project output directory which is
// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
// located in the project directory, you would specify the AssemblyKeyFile
// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
// documentation for more information on this.
//
[assembly: AssemblyDelaySign(false)]
[assembly: AssemblyKeyFile("")]
[assembly: AssemblyKeyName("")]
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<RevitAddIns>
<AddIn Type="Command">
<Assembly>BeamAndSlabNewParameter.dll</Assembly>
<ClientId>4918f2e4-b94a-4511-aa25-78c8c16cb7fc</ClientId>
<FullClassName>Revit.SDK.Samples.BeamAndSlabNewParameter.CS.Command</FullClassName>
<Text>Beam and slab parameter</Text>
<Description>Add a new GUID parameter to beam and slab, and use the GUID value to find the right element.</Description>
<VisibilityMode>AlwaysVisible</VisibilityMode>
<VendorId>ADSK</VendorId>
<VendorDescription>Autodesk, www.autodesk.com</VendorDescription>
</AddIn>
</RevitAddIns>
@@ -0,0 +1,377 @@
//
// (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.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Windows.Forms;
using Autodesk.Revit;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
namespace Revit.SDK.Samples.BeamAndSlabNewParameter.CS
{
/// <summary>
/// Display how to add a parameter to an element and set value to the parameter.
/// the class supports the IExternalCommand interface
/// </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
{
Autodesk.Revit.UI.UIApplication m_revit; // application of Revit
ElementSet m_elements; // correspond to elements parameter in Execute(...)
/// <summary>
/// Implement this method as an external command for Revit.
/// </summary>
/// <param name="revit">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 revit,
ref string message,
ElementSet elements)
{
// Set currently executable application to private variable m_revit
m_revit = revit.Application;
m_elements = elements;
Transaction tran = new Transaction(m_revit.ActiveUIDocument.Document, "BeamAndSlabNewParameter");
tran.Start();
// Show UI
using (BeamAndSlabParametersForm displayForm = new BeamAndSlabParametersForm(this))
{
displayForm.ShowDialog();
}
tran.Commit();
return Autodesk.Revit.UI.Result.Succeeded;
}
/// <summary>
/// Add a new parameter, "Unique ID", to the beams and slabs
/// The following process should be followed:
/// Open the shared parameters file, via the Document.OpenSharedParameterFile method.
/// Access an existing group or create a new group, via the DefinitionFile.Groups property.
/// Access an existing or create a new external parameter definition,
/// via the DefinitionGroup.Definitions property.
/// Create a new Binding with the categories to which the parameter will be bound
/// using an InstanceBinding or a TypeBinding.
/// Finally add the binding and definition to the document
/// using the Document.ParameterBindings object.
/// </summary>
/// <returns>bool type, a value that signifies if add parameter was successful</returns>
public bool SetNewParameterToBeamsAndSlabs ()
{
//Open the shared parameters file
// via the private method AccessOrCreateExternalSharedParameterFile
DefinitionFile informationFile = AccessOrCreateExternalSharedParameterFile();
if (null == informationFile)
{
return false;
}
// Access an existing or create a new group in the shared parameters file
DefinitionGroups informationCollections = informationFile.Groups;
DefinitionGroup informationCollection = null;
informationCollection = informationCollections.get_Item("MyParameters");
if (null == informationCollection)
{
informationCollections.Create("MyParameters");
informationCollection = informationCollections.get_Item("MyParameters");
}
// Access an existing or create a new external parameter definition
// belongs to a specific group
Definition information = informationCollection.Definitions.get_Item("Unique ID");
if (null == information)
{
ExternalDefinitionCreationOptions ExternalDefinitionCreationOptions = new ExternalDefinitionCreationOptions("Unique ID", Autodesk.Revit.DB.SpecTypeId.String.Text);
informationCollection.Definitions.Create(ExternalDefinitionCreationOptions);
information = informationCollection.Definitions.get_Item("Unique ID");
}
// Create a new Binding object with the categories to which the parameter will be bound
CategorySet categories = m_revit.Application.Create.NewCategorySet();
Category structuralFramingCategorie = null;
Category floorsClassification = null;
// use category in instead of the string name to get category
structuralFramingCategorie = m_revit.ActiveUIDocument.Document.Settings.Categories.get_Item(BuiltInCategory.OST_StructuralFraming);
floorsClassification = m_revit.ActiveUIDocument.Document.Settings.Categories.get_Item(BuiltInCategory.OST_Floors);
categories.Insert(structuralFramingCategorie);
categories.Insert(floorsClassification);
InstanceBinding caseTying = m_revit.Application.Create.NewInstanceBinding(categories);
// Add the binding and definition to the document
bool boundResult = m_revit.ActiveUIDocument.Document.ParameterBindings.Insert(information, caseTying);
return boundResult;
}
/// <summary>
/// Set value(uuid) to Unique ID parameter
/// </summary>
public void SetValueToUniqueIDParameter()
{
ElementClassFilter beamClassFilter = new ElementClassFilter(typeof(FamilyInstance));
ElementClassFilter slabClassFilter = new ElementClassFilter(typeof(Floor));
ElementCategoryFilter beamTypeFilter = new ElementCategoryFilter(BuiltInCategory.OST_StructuralFraming);
ElementCategoryFilter slabTypeFilter = new ElementCategoryFilter(BuiltInCategory.OST_Floors);
LogicalAndFilter beamFilter = new LogicalAndFilter(beamClassFilter,beamTypeFilter);
LogicalAndFilter slabFilter = new LogicalAndFilter(slabClassFilter,slabTypeFilter);
LogicalOrFilter beamandslabFilter = new LogicalOrFilter(beamFilter, slabFilter);
IEnumerable<Element> elems = from elem in
new FilteredElementCollector(m_revit.ActiveUIDocument.Document).WherePasses(beamandslabFilter).ToElements()
select elem;
foreach (Element elem in elems)
{
// Find the parameter which is named "Unique ID"
// belongs to a specifically beam or slab
ParameterSet attributes = elem.Parameters;
IEnumerator iter = attributes.GetEnumerator();
iter.Reset();
while (iter.MoveNext())
{
Parameter attribute = iter.Current as Autodesk.Revit.DB.Parameter;
Definition information = attribute.Definition;
if ((null != information)&&("Unique ID" == information.Name) && (null == attribute.AsString()) )
{
// The shared parameter "Unique ID" then be set to a UUID
Guid uuid = Guid.NewGuid();
attribute.Set(uuid.ToString());
}
}
}
}
/// <summary>
/// Display the value of Unique ID parameter in a list box
/// </summary>
/// <returns></returns>
public System.Collections.ArrayList SendValueToListBox()
{
ElementSet elements = new ElementSet();
foreach (ElementId elementId in m_revit.ActiveUIDocument.Selection.GetElementIds())
{
elements.Insert(m_revit.ActiveUIDocument.Document.GetElement(elementId));
}
// all the elements of current document
IEnumerator i = elements.GetEnumerator();
ArrayList parameterValueArrangeBox = new ArrayList();
// if the selections include beams and slabs, find out their Unique ID's value for display
i.Reset();
bool moreElements = i.MoveNext();
while (moreElements)
{
// Get beams and slabs from selections
Element component = i.Current as Autodesk.Revit.DB.Element;
if (null == component)
{
moreElements = i.MoveNext();
continue;
}
if (null == component.Category)
{
moreElements = i.MoveNext();
continue;
}
if (("Structural Framing" != component.Category.Name) &&
("Floors" != component.Category.Name))
{
moreElements = i.MoveNext();
continue;
}
// Get "Unique ID" parameter and display its value in a list box
ParameterSet attributes = component.Parameters;
foreach(object o in attributes)
{
Parameter attribute = o as Parameter;
if ("Unique ID" == attribute.Definition.Name)
{
if (null == attribute.AsString())
{
break;
}
parameterValueArrangeBox.Add(attribute.AsString());
break;
}
}
moreElements = i.MoveNext();
}
return parameterValueArrangeBox;
}
/// <summary>
/// found the element which using the GUID
/// that was assigned to the shared parameter in the shared parameters file.
/// </summary>
/// <param name="UniqueIdValue"></param>
public void FindElement(string UniqueIdValue)
{
ElementSet seleElements = new ElementSet();
foreach (ElementId elementId in m_revit.ActiveUIDocument.Selection.GetElementIds())
{
seleElements.Insert(m_revit.ActiveUIDocument.Document.GetElement(elementId));
}
// all the elements of current document
IEnumerator i = seleElements.GetEnumerator();
// if the selections include beams and slabs,
// find out the element using the select value for display
i.Reset();
bool moreElements = i.MoveNext();
while (moreElements)
{
// Get beams and slabs from selections
Element component = i.Current as Autodesk.Revit.DB.Element;
if (null == component)
{
moreElements = i.MoveNext();
continue;
}
if (null == component.Category)
{
moreElements = i.MoveNext();
continue;
}
if (("Structural Framing" != component.Category.Name) &&
("Floors" != component.Category.Name))
{
moreElements = i.MoveNext();
continue;
}
// Get "Unique ID" parameter
ParameterSet attributes = component.Parameters;
foreach (object o in attributes)
{
Parameter attribute = o as Parameter;
if ("Unique ID" == attribute.Definition.Name)
{
if (null == attribute.AsString())
{
break;
}
// compare if the parameter's value is the same as the selected value.
// Clear the SelElementSet and add the found element into it.
// So this element will highlight in Revit UI
if (UniqueIdValue == attribute.AsString())
{
seleElements.Clear();
seleElements.Insert(component);
return;
}
break;
}
}
moreElements = i.MoveNext();
}
}
/// <summary>
/// Access an existing or create a new shared parameters file
/// </summary>
/// <returns>a shared parameters file </returns>
private DefinitionFile AccessOrCreateExternalSharedParameterFile()
{
// The Path of Revit.exe
string currentExecutablePath = System.Windows.Forms.Application.ExecutablePath;
// The path of ourselves shared parameters file
string sharedParameterFile = Path.GetDirectoryName(currentExecutablePath);
sharedParameterFile = sharedParameterFile + "\\MySharedParameters.txt";
//Method's return
DefinitionFile informationFile = null;
// Check if the file is exit
System.IO.FileInfo documentMessage = new FileInfo(sharedParameterFile);
bool fileExist = documentMessage.Exists;
// Create file for external shared parameter since it does not exist
if (!fileExist)
{
FileStream fileFlow = File.Create(sharedParameterFile);
fileFlow.Close();
}
// Set ourselves file to the externalSharedParameterFile
m_revit.Application.SharedParametersFilename = sharedParameterFile;
informationFile = m_revit.Application.OpenSharedParameterFile();
return informationFile;
}
}
}
@@ -0,0 +1,149 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectType>Local</ProjectType>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{14B16804-1586-4D7F-8B43-D48C3EA15AE8}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ApplicationIcon>
</ApplicationIcon>
<AssemblyKeyContainerName>
</AssemblyKeyContainerName>
<AssemblyName>BeamAndSlabNewParameter</AssemblyName>
<AssemblyOriginatorKeyFile>
</AssemblyOriginatorKeyFile>
<DefaultClientScript>JScript</DefaultClientScript>
<DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
<DefaultTargetSchema>IE50</DefaultTargetSchema>
<DelaySign>false</DelaySign>
<OutputType>Library</OutputType>
<RootNamespace>Revit.SDK.Samples.BeamAndSlabParameters.CS</RootNamespace>
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
<StartupObject>
</StartupObject>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<OutputPath>bin\Debug\</OutputPath>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DocumentationFile>
</DocumentationFile>
<DebugSymbols>true</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<NoStdLib>false</NoStdLib>
<NoWarn>
</NoWarn>
<Optimize>false</Optimize>
<RegisterForComInterop>false</RegisterForComInterop>
<RemoveIntegerChecks>false</RemoveIntegerChecks>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<DebugType>full</DebugType>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<OutputPath>bin\Release\</OutputPath>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE</DefineConstants>
<DocumentationFile>
</DocumentationFile>
<DebugSymbols>false</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<NoStdLib>false</NoStdLib>
<NoWarn>
</NoWarn>
<Optimize>true</Optimize>
<RegisterForComInterop>false</RegisterForComInterop>
<RemoveIntegerChecks>false</RemoveIntegerChecks>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<DebugType>none</DebugType>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<BaseAddress>285212672</BaseAddress>
<FileAlignment>4096</FileAlignment>
<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>
<BaseAddress>285212672</BaseAddress>
<Optimize>true</Optimize>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<FileAlignment>4096</FileAlignment>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup>
<RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent>
</PropertyGroup>
<ItemGroup>
<Reference Include="System">
<Name>System</Name>
</Reference>
<Reference Include="System.Data">
<Name>System.Data</Name>
</Reference>
<Reference Include="System.Drawing">
<Name>System.Drawing</Name>
</Reference>
<Reference Include="System.Windows.Forms">
<Name>System.Windows.Forms</Name>
</Reference>
<Reference Include="System.Xml">
<Name>System.XML</Name>
</Reference>
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="BeamAndSlabNewParameter.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="BeamAndSlabNewParameterForm.cs">
<SubType>Form</SubType>
</Compile>
<EmbeddedResource Include="BeamAndSlabNewParameterForm.resx">
<DependentUpon>BeamAndSlabNewParameterForm.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(SolutionDir)VSProps\SDKSamples.targets" />
<PropertyGroup>
<PreBuildEvent>
</PreBuildEvent>
<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,244 @@
//
// (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.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using Autodesk.Revit.UI;
namespace Revit.SDK.Samples.BeamAndSlabNewParameter.CS
{
/// <summary>
/// User Interface.
/// </summary>
public class BeamAndSlabParametersForm : System.Windows.Forms.Form
{
private System.Windows.Forms.Button addParameterButton;
private System.Windows.Forms.Button displayValueButton;
private System.Windows.Forms.Button exitButton;
private System.Windows.Forms.ListBox attributeValueListBox;
private System.Windows.Forms.Label attributeValueLabel;
private Button findButton;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
/// <summary>
/// constructor
/// </summary>
/// <param name="dataBuffer"></param>
public BeamAndSlabParametersForm(Command dataBuffer)
{
InitializeComponent();
m_dataBuffer = dataBuffer;
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(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.addParameterButton = new System.Windows.Forms.Button();
this.displayValueButton = new System.Windows.Forms.Button();
this.exitButton = new System.Windows.Forms.Button();
this.attributeValueListBox = new System.Windows.Forms.ListBox();
this.attributeValueLabel = new System.Windows.Forms.Label();
this.findButton = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// addParameterButton
//
this.addParameterButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.addParameterButton.Location = new System.Drawing.Point(311, 65);
this.addParameterButton.Name = "addParameterButton";
this.addParameterButton.Size = new System.Drawing.Size(105, 26);
this.addParameterButton.TabIndex = 1;
this.addParameterButton.Text = "&Add";
this.addParameterButton.TextAlign = System.Drawing.ContentAlignment.TopCenter;
this.addParameterButton.Click += new System.EventHandler(this.addParameterButton_Click);
//
// displayValueButton
//
this.displayValueButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.displayValueButton.Location = new System.Drawing.Point(311, 111);
this.displayValueButton.Name = "displayValueButton";
this.displayValueButton.Size = new System.Drawing.Size(105, 26);
this.displayValueButton.TabIndex = 2;
this.displayValueButton.Text = "&Display Value";
this.displayValueButton.Click += new System.EventHandler(this.displayValueButton_Click);
//
// exitButton
//
this.exitButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.exitButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.exitButton.Location = new System.Drawing.Point(311, 203);
this.exitButton.Name = "exitButton";
this.exitButton.Size = new System.Drawing.Size(105, 26);
this.exitButton.TabIndex = 4;
this.exitButton.Text = "&Exit";
this.exitButton.Click += new System.EventHandler(this.exitButton_Click);
//
// attributeValueListBox
//
this.attributeValueListBox.ItemHeight = 16;
this.attributeValueListBox.Location = new System.Drawing.Point(19, 46);
this.attributeValueListBox.Name = "attributeValueListBox";
this.attributeValueListBox.Size = new System.Drawing.Size(269, 228);
this.attributeValueListBox.TabIndex = 18;
this.attributeValueListBox.TabStop = false;
//
// attributeValueLabel
//
this.attributeValueLabel.Location = new System.Drawing.Point(19, 9);
this.attributeValueLabel.Name = "attributeValueLabel";
this.attributeValueLabel.Size = new System.Drawing.Size(279, 37);
this.attributeValueLabel.TabIndex = 19;
this.attributeValueLabel.Text = "Display the value of the Unique ID if present for all the selected elements";
//
// findButton
//
this.findButton.DialogResult = System.Windows.Forms.DialogResult.OK;
this.findButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.findButton.Location = new System.Drawing.Point(311, 157);
this.findButton.Name = "findButton";
this.findButton.Size = new System.Drawing.Size(105, 26);
this.findButton.TabIndex = 3;
this.findButton.Text = "&Find";
this.findButton.Click += new System.EventHandler(this.findButton_Click);
//
// BeamAndSlabParametersForm
//
this.CancelButton = this.exitButton;
this.ClientSize = new System.Drawing.Size(438, 292);
this.Controls.Add(this.attributeValueLabel);
this.Controls.Add(this.attributeValueListBox);
this.Controls.Add(this.addParameterButton);
this.Controls.Add(this.findButton);
this.Controls.Add(this.displayValueButton);
this.Controls.Add(this.exitButton);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "BeamAndSlabParametersForm";
this.ShowInTaskbar = false;
this.Text = "Beam and Slab New Parameters";
this.ResumeLayout(false);
}
#endregion
// an instance of Command class
Command m_dataBuffer = null;
/// <summary>
/// Call SetNewParameterToBeamsAndSlabs function
/// which is belongs to BeamAndSlabParameters class
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void addParameterButton_Click(object sender, System.EventArgs e)
{
bool successAddParameter = m_dataBuffer.SetNewParameterToBeamsAndSlabs();
if (successAddParameter)
{
this.DialogResult = DialogResult.OK;
m_dataBuffer.SetValueToUniqueIDParameter();
TaskDialog.Show("Revit", "Done");
}
else
{
this.DialogResult = DialogResult.None;
m_dataBuffer.SetValueToUniqueIDParameter();
TaskDialog.Show("Revit", "Unique ID parameter exist");
}
}
/// <summary>
/// Call SetValueToUniqueIDParameter function
/// which is belongs to BeamAndSlabNewParameters class
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void findButton_Click(object sender, System.EventArgs e)
{
if (null != attributeValueListBox.SelectedItem)
{
m_dataBuffer.FindElement(attributeValueListBox.SelectedItem.ToString());
}
}
/// <summary>
/// Call SendValueToListBox function which is belongs to BeamAndSlabNewParameters class
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void displayValueButton_Click(object sender, System.EventArgs e)
{
attributeValueListBox.DataSource = m_dataBuffer.SendValueToListBox();
//If we displayed nothing, give possible reasons
if (0 == attributeValueListBox.Items.Count)
{
string message = "";
message = "There was an error executing the command.\r\n";
message = message + "Possible reasons for this are:\r\n\r\n";
message = message + "1. No parameter was added.\r\n";
message = message + "2. No beam or slab was selected.\r\n";
message = message + "3. The value was blank.\r\n";
TaskDialog.Show("Revit", message);
}
}
/// <summary>
/// Close this form
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void exitButton_Click(object sender, System.EventArgs e)
{
this.Close();
}
}
}
@@ -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>