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>RotateFramingObjects.dll</Assembly>
<ClientId>c71ee76a-a962-4434-b610-0ed5e18e03cf</ClientId>
<FullClassName>Revit.SDK.Samples.RotateFramingObjects.CS.RotateFramingObjects</FullClassName>
<Text>Rotate Framing Objects (CS)</Text>
<Description>Rotate selected objects, such as beams, braces and columns.</Description>
<VisibilityMode>AlwaysVisible</VisibilityMode>
<VendorId>ADSK</VendorId>
<VendorDescription>Autodesk, www.autodesk.com</VendorDescription>
</AddIn>
</RevitAddIns>
@@ -0,0 +1,362 @@
//
// (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.Windows.Forms;
using Autodesk;
using Autodesk.Revit;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Structure;
using Autodesk.Revit.UI;
namespace Revit.SDK.Samples.RotateFramingObjects.CS
{
/// <summary>
/// Rotate the objects that were selected when the command was executed.
/// and allow the user input the amount, in degrees that the objects should be rotated.
/// the dialog contain option for the user to specify this value is absolute or relative.
/// </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 RotateFramingObjects : IExternalCommand
{
Autodesk.Revit.UI.UIApplication m_revit = null; // application of Revit
double m_receiveRotationTextBox; // receive change of Angle
bool m_isAbsoluteChecked; // true if moving absolute
const string AngleDefinitionName = "Cross-Section Rotation";
/// <summary>
/// receive change of Angle
/// </summary>
public double ReceiveRotationTextBox
{
get
{
return m_receiveRotationTextBox;
}
set
{
m_receiveRotationTextBox = value;
}
}
/// <summary>
/// is moving absolutely
/// </summary>
public bool IsAbsoluteChecked
{
get
{
return m_isAbsoluteChecked;
}
set
{
m_isAbsoluteChecked = value;
}
}
/// <summary>
/// Default constructor of RotateFramingObjects
/// </summary>
public RotateFramingObjects()
{ }
/// <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, Autodesk.Revit.DB.ElementSet elements)
{
Autodesk.Revit.UI.UIApplication revit = commandData.Application;
m_revit = revit;
RotateFramingObjectsForm displayForm = new RotateFramingObjectsForm(this);
displayForm.StartPosition = FormStartPosition.CenterParent;
ElementSet selection = new ElementSet();
foreach (ElementId elementId in revit.ActiveUIDocument.Selection.GetElementIds())
{
selection.Insert(revit.ActiveUIDocument.Document.GetElement(elementId));
}
bool isSingle = true; //selection is single object
bool isAllFamilyInstance = true; //all is not familyInstance
// There must be beams, braces or columns selected
if (selection.IsEmpty)
{
// nothing selected
message = "Please select some beams, braces or columns.";
return Autodesk.Revit.UI.Result.Failed;
}
else if (1 != selection.Size)
{
isSingle = false;
try
{
if (DialogResult.OK != displayForm.ShowDialog())
{
return Autodesk.Revit.UI.Result.Cancelled;
}
}
catch (Exception)
{
return Autodesk.Revit.UI.Result.Failed;
}
// return Autodesk.Revit.UI.Result.Succeeded;
// more than one object selected
}
// if the selected elements are familyInstances, try to get their existing rotation
foreach (Autodesk.Revit.DB.Element e in selection)
{
FamilyInstance familyComponent = e as FamilyInstance;
if (familyComponent != null)
{
if (StructuralType.Beam == familyComponent.StructuralType
|| StructuralType.Brace == familyComponent.StructuralType)
{
// selection is a beam or brace
string returnValue = this.FindParameter(AngleDefinitionName, familyComponent);
displayForm.rotationTextBox.Text = returnValue.ToString();
}
else if (StructuralType.Column == familyComponent.StructuralType)
{
// selection is a column
Location columnLocation = familyComponent.Location;
LocationPoint pointLocation = columnLocation as LocationPoint;
double temp = pointLocation.Rotation;
string output = (Math.Round(temp * 180 / (Math.PI), 3)).ToString();
displayForm.rotationTextBox.Text = output;
}
else
{
// other familyInstance can not be rotated
message = "It is not a beam, brace or column.";
elements.Insert(familyComponent);
return Autodesk.Revit.UI.Result.Failed;
}
}
else
{
if (isSingle)
{
message = "It is not a FamilyInstance.";
elements.Insert(e);
return Autodesk.Revit.UI.Result.Failed;
}
// there is some objects is not familyInstance
message = "They are not FamilyInstances";
elements.Insert(e);
isAllFamilyInstance = false;
}
}
if (isSingle)
{
try
{
if (DialogResult.OK != displayForm.ShowDialog())
{
return Autodesk.Revit.UI.Result.Cancelled;
}
}
catch (Exception)
{
return Autodesk.Revit.UI.Result.Failed;
}
}
if (isAllFamilyInstance)
{
return Autodesk.Revit.UI.Result.Succeeded;
}
else
{
//output error information
return Autodesk.Revit.UI.Result.Failed;
}
}
/// <summary>
/// The function set value to rotation of the beams and braces
/// and rotate columns.
/// </summary>
public void RotateElement()
{
Transaction transaction = new Transaction(m_revit.ActiveUIDocument.Document, "RotateElement");
transaction.Start();
try
{
ElementSet selection = new ElementSet();
foreach (ElementId elementId in m_revit.ActiveUIDocument.Selection.GetElementIds())
{
selection.Insert(m_revit.ActiveUIDocument.Document.GetElement(elementId));
}
foreach (Autodesk.Revit.DB.Element e in selection)
{
FamilyInstance familyComponent = e as FamilyInstance;
if (familyComponent == null)
{
//is not a familyInstance
continue;
}
// if be familyInstance,judge the types of familyInstance
if (StructuralType.Beam == familyComponent.StructuralType
|| StructuralType.Brace == familyComponent.StructuralType)
{
// selection is a beam or Brace
ParameterSetIterator paraIterator = familyComponent.Parameters.ForwardIterator();
paraIterator.Reset();
while (paraIterator.MoveNext())
{
object para = paraIterator.Current;
Parameter objectAttribute = para as Parameter;
//set generic property named "Cross-Section Rotation"
if (objectAttribute.Definition.Name.Equals(AngleDefinitionName))
{
Double originDegree = objectAttribute.AsDouble();
double rotateDegree = m_receiveRotationTextBox * Math.PI / 180;
if (!m_isAbsoluteChecked)
{
// absolute rotation
rotateDegree += originDegree;
}
objectAttribute.Set(rotateDegree);
// relative rotation
}
}
}
else if (StructuralType.Column == familyComponent.StructuralType)
{
// rotate a column
Autodesk.Revit.DB.Location columnLocation = familyComponent.Location;
// get the location object
LocationPoint pointLocation = columnLocation as LocationPoint;
Autodesk.Revit.DB.XYZ insertPoint = pointLocation.Point;
// get the location point
double temp = pointLocation.Rotation;
//existing rotation
Autodesk.Revit.DB.XYZ directionPoint = new Autodesk.Revit.DB.XYZ(0, 0, 1);
// define the vector of axis
Line rotateAxis = Line.CreateUnbound(insertPoint, directionPoint);
double rotateDegree = m_receiveRotationTextBox * Math.PI / 180;
// rotate column by rotate method
if (m_isAbsoluteChecked)
{
rotateDegree -= temp;
}
bool rotateResult = pointLocation.Rotate(rotateAxis, rotateDegree);
if (rotateResult == false)
{
TaskDialog.Show("Revit", "Rotate Failed.");
}
}
}
transaction.Commit();
}
catch (Exception ex)
{
TaskDialog.Show("Revit", "Rotate failed! " + ex.Message);
transaction.RollBack();
}
}
/// <summary>
/// get the parameter value according given parameter name
/// </summary>
public string FindParameter(string parameterName, FamilyInstance familyInstanceName)
{
ParameterSetIterator i = familyInstanceName.Parameters.ForwardIterator();
i.Reset();
string valueOfParameter = null;
bool iMoreAttribute = i.MoveNext();
while (iMoreAttribute)
{
bool isFound = false;
object o = i.Current;
Parameter familyAttribute = o as Parameter;
if (familyAttribute.Definition.Name == parameterName)
{
//find the parameter whose name is same to the given parameter name
Autodesk.Revit.DB.StorageType st = familyAttribute.StorageType;
switch (st)
{
//get the storage type
case StorageType.Double:
if (parameterName.Equals(AngleDefinitionName))
{
//make conversion between degrees and radians
Double temp = familyAttribute.AsDouble();
valueOfParameter = Math.Round(temp * 180 / (Math.PI), 3).ToString();
}
else
{
valueOfParameter = familyAttribute.AsDouble().ToString();
}
break;
case StorageType.ElementId:
//get Autodesk.Revit.DB.ElementId as string
valueOfParameter = familyAttribute.AsElementId().IntegerValue.ToString();
break;
case StorageType.Integer:
//get Integer as string
valueOfParameter = familyAttribute.AsInteger().ToString();
break;
case StorageType.String:
//get string
valueOfParameter = familyAttribute.AsString();
break;
case StorageType.None:
valueOfParameter = familyAttribute.AsValueString();
break;
default:
break;
}
isFound = true;
}
if (isFound)
{
break;
}
iMoreAttribute = i.MoveNext();
}
//return the value.
return valueOfParameter;
}
}
}
@@ -0,0 +1,192 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="12.0">
<PropertyGroup>
<ProjectType>Local</ProjectType>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{48A33B6D-7E0A-4F17-9E8F-47A85E87B532}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ApplicationIcon>
</ApplicationIcon>
<AssemblyKeyContainerName>
</AssemblyKeyContainerName>
<AssemblyName>RotateFramingObjects</AssemblyName>
<AssemblyOriginatorKeyFile>
</AssemblyOriginatorKeyFile>
<DefaultClientScript>JScript</DefaultClientScript>
<DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
<DefaultTargetSchema>IE50</DefaultTargetSchema>
<DelaySign>false</DelaySign>
<OutputType>Library</OutputType>
<RootNamespace>RotateFramingObjects</RootNamespace>
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
<StartupObject>
</StartupObject>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>2.0</OldToolsVersion>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<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="RotateFramingObjects.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="RotateFramingObjectsForm.cs">
<SubType>Form</SubType>
</Compile>
<EmbeddedResource Include="RotateFramingObjectsForm.resx">
<DependentUpon>RotateFramingObjectsForm.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.2.0">
<Visible>False</Visible>
<ProductName>.NET Framework 2.0 %28x86%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.0">
<Visible>False</Visible>
<ProductName>.NET Framework 3.0 %28x86%29</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</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,254 @@
//
// (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.RotateFramingObjects.CS
{
/// <summary>
/// Summary description for PutDialog.
/// </summary>
public class RotateFramingObjectsForm : System.Windows.Forms.Form
{
private RotateFramingObjects m_instance;
private System.ComponentModel.Container m_components = null;
private System.Windows.Forms.Button cancelButton;
private System.Windows.Forms.Button okButton;
public System.Windows.Forms.RadioButton absoluteRadio;
private System.Windows.Forms.RadioButton relativeRadio;
private System.Windows.Forms.Label rotationLabel;
public System.Windows.Forms.TextBox rotationTextBox;
private bool m_isReset;
/// <summary>
///
/// </summary>
public bool IsReset
{
get
{
return m_isReset;
}
set
{
m_isReset = value;
}
}
/// <summary>
/// new form, retrieve relevant data from instance
/// </summary>
/// <param name="Inst">RotateFramingObjects instance</param>
public RotateFramingObjectsForm(RotateFramingObjects Inst)
{
m_isReset = false;
m_instance = Inst;
if (null == m_instance)
{
TaskDialog.Show("Revit", "Load Application Failed");
}
InitializeComponent();
//this.rotationTextBox.Text = "Value";
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(m_components != null)
{
m_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.absoluteRadio = new System.Windows.Forms.RadioButton();
this.relativeRadio = new System.Windows.Forms.RadioButton();
this.cancelButton = new System.Windows.Forms.Button();
this.okButton = new System.Windows.Forms.Button();
this.rotationLabel = new System.Windows.Forms.Label();
this.rotationTextBox = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// absoluteRadio
//
this.absoluteRadio.Location = new System.Drawing.Point(85, 35);
this.absoluteRadio.Name = "absoluteRadio";
this.absoluteRadio.Size = new System.Drawing.Size(72, 24);
this.absoluteRadio.TabIndex = 0;
this.absoluteRadio.Text = "Absolute";
this.absoluteRadio.CheckedChanged += new System.EventHandler(this.allRadio_CheckedChanged);
//
// relativeRadio
//
this.relativeRadio.Checked = true;
this.relativeRadio.Location = new System.Drawing.Point(15, 35);
this.relativeRadio.Name = "relativeRadio";
this.relativeRadio.Size = new System.Drawing.Size(64, 24);
this.relativeRadio.TabIndex = 1;
this.relativeRadio.TabStop = true;
this.relativeRadio.Text = "Relative";
this.relativeRadio.CheckedChanged += new System.EventHandler(this.singleRadio_CheckedChanged);
//
// cancelButton
//
this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.cancelButton.Location = new System.Drawing.Point(93, 65);
this.cancelButton.Name = "cancelButton";
this.cancelButton.Size = new System.Drawing.Size(75, 23);
this.cancelButton.TabIndex = 6;
this.cancelButton.Text = "&Cancel";
this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
//
// okButton
//
this.okButton.Location = new System.Drawing.Point(15, 65);
this.okButton.Name = "okButton";
this.okButton.Size = new System.Drawing.Size(75, 23);
this.okButton.TabIndex = 8;
this.okButton.Text = "&OK";
this.okButton.Click += new System.EventHandler(this.okButton_Click);
//
// rotationLabel
//
this.rotationLabel.Location = new System.Drawing.Point(12, 12);
this.rotationLabel.Name = "rotationLabel";
this.rotationLabel.Size = new System.Drawing.Size(50, 16);
this.rotationLabel.TabIndex = 10;
this.rotationLabel.Text = "Rotation";
//
// rotationTextBox
//
this.rotationTextBox.Location = new System.Drawing.Point(68, 9);
this.rotationTextBox.Name = "rotationTextBox";
this.rotationTextBox.Size = new System.Drawing.Size(100, 20);
this.rotationTextBox.TabIndex = 1;
this.rotationTextBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.rotationTextBox_KeyPress);
this.rotationTextBox.TextChanged += new System.EventHandler(this.rotationTextBox_TextChanged);
//
// RotateFramingObjectsForm
//
this.AcceptButton = this.okButton;
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.CancelButton = this.cancelButton;
this.ClientSize = new System.Drawing.Size(185, 101);
this.Controls.Add(this.rotationTextBox);
this.Controls.Add(this.relativeRadio);
this.Controls.Add(this.rotationLabel);
this.Controls.Add(this.okButton);
this.Controls.Add(this.cancelButton);
this.Controls.Add(this.absoluteRadio);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "RotateFramingObjectsForm";
this.ShowInTaskbar = false;
this.Text = "Rotate Framing Objects";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private void okButton_Click(object sender, System.EventArgs e)
{
if(IsReset)
{
m_instance.RotateElement();
}
this.DialogResult=DialogResult.OK;
this.Close();
}
private void cancelButton_Click(object sender, System.EventArgs e)
{
this.DialogResult=DialogResult.Cancel;
this.Close();
}
private void singleRadio_CheckedChanged(object sender, System.EventArgs e)
{
m_isReset = true;
m_instance.IsAbsoluteChecked = false;
}
private void allRadio_CheckedChanged(object sender, System.EventArgs e)
{
m_isReset = true;
m_instance.IsAbsoluteChecked = true;
}
private void rotationTextBox_TextChanged(object sender, System.EventArgs e)
{
if("" != this.rotationTextBox.Text)
{
try
{
m_instance.ReceiveRotationTextBox = Convert.ToDouble(this.rotationTextBox.Text);
}
catch (Exception)
{
//this.DialogResult=DialogResult.Cancel;
TaskDialog.Show("Revit", "Please input number.");
this.rotationTextBox.Clear();
}
}
else
{
m_instance.ReceiveRotationTextBox = 0;
}
m_isReset = true;
}
private void rotationTextBox_KeyPress(object sender, KeyPressEventArgs e)
{
if (13 == e.KeyChar)
{
okButton_Click(sender,e);
}
else
rotationTextBox_TextChanged(sender,e);
}
}
}
@@ -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>