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
+118
View File
@@ -0,0 +1,118 @@
//
// (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 System.Windows.Forms;
using Revit.SDK.Samples.NewRoof.RoofForms.CS;
using Autodesk.Revit;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
namespace Revit.SDK.Samples.NewRoof.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
{
// internal buffer
private static Autodesk.Revit.DB.View m_activeView;
/// <summary>
/// singleton in the external application
/// </summary>
public static Autodesk.Revit.DB.View ActiveView
{
get
{
return m_activeView;
}
}
/// <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
{
m_activeView = commandData.Application.ActiveUIDocument.Document.ActiveView;
//// Create a new instance of class DataManager
RoofsManager.CS.RoofsManager roofsManager = new RoofsManager.CS.RoofsManager(commandData);
LevelConverter.SetStandardValues(roofsManager.Levels);
// Create a form to create and edit a roof.
DialogResult result = System.Windows.Forms.DialogResult.None;
while (result == DialogResult.None || result == DialogResult.Retry)
{
if (result == DialogResult.Retry)
{
roofsManager.WindowSelect();
}
using (RoofForms.CS.RoofForm mainForm = new RoofForms.CS.RoofForm(roofsManager))
{
result = mainForm.ShowDialog();
}
}
if (result == System.Windows.Forms.DialogResult.OK)
{
return Autodesk.Revit.UI.Result.Succeeded;
}
else
{
return Autodesk.Revit.UI.Result.Cancelled;
}
}
catch (Exception ex)
{
// If there are something wrong, give error information and return failed
message = ex.Message;
return Autodesk.Revit.UI.Result.Failed;
}
}
}
}
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0"?>
<RevitAddIns>
<AddIn Type="Command">
<Assembly>NewRoof.dll</Assembly>
<ClientId>f6c0eb19-34e0-4d0f-9e6f-fd57658924a9</ClientId>
<FullClassName>Revit.SDK.Samples.NewRoof.CS.Command</FullClassName>
<Text>NewRoof</Text>
<Description>Create or edit footprint roof and extrusion roof.</Description>
<VisibilityMode>AlwaysVisible</VisibilityMode>
<VendorId>ADSK</VendorId>
<VendorDescription>Autodesk, www.autodesk.com</VendorDescription>
</AddIn>
</RevitAddIns>
+124
View File
@@ -0,0 +1,124 @@
<?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>{1BB53C76-C784-4490-9CB2-CF9AEC00C3A3}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>NewRoof</RootNamespace>
<AssemblyName>NewRoof</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>
</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="RoofForms\CustomTypeConverter.cs" />
<Compile Include="RoofForms\ExtrusionRoofWrapper.cs" />
<Compile Include="RoofForms\FootPrintRoofWrapper.cs" />
<Compile Include="RoofForms\RoofEditorForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="RoofForms\RoofEditorForm.Designer.cs">
<DependentUpon>RoofEditorForm.cs</DependentUpon>
</Compile>
<Compile Include="RoofForms\RoofForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="RoofForms\RoofForm.Designer.cs">
<DependentUpon>RoofForm.cs</DependentUpon>
</Compile>
<Compile Include="RoofForms\RoofItem.cs" />
<Compile Include="RoofForms\GraphicsControl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="RoofForms\GraphicsControl.Designer.cs">
<DependentUpon>GraphicsControl.cs</DependentUpon>
</Compile>
<Compile Include="RoofsManager\ExtrusionRoofManager.cs" />
<Compile Include="RoofsManager\FootPrintRoofManager.cs" />
<Compile Include="RoofsManager\RoofsManager.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="RoofForms\RoofEditorForm.resx">
<SubType>Designer</SubType>
<DependentUpon>RoofEditorForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="RoofForms\RoofForm.resx">
<SubType>Designer</SubType>
<DependentUpon>RoofForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="RoofForms\GraphicsControl.resx">
<SubType>Designer</SubType>
<DependentUpon>GraphicsControl.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,57 @@
//
// (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("NewRoof")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("NewRoof")]
[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("9ebcf0be-8c3a-44bc-a56d-f05801051f7c")]
// 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")]
+78
View File
@@ -0,0 +1,78 @@
{\rtf1\fbidis\ansi\ansicpg1252\deff0\deflang1033\deflangfe2052\deftab420{\fonttbl{\f0\fswiss\fprq2\fcharset0 Arial;}{\f1\froman\fprq2\fcharset0 Times New Roman;}{\f2\fmodern\fprq1\fcharset0 Courier New;}}
{\colortbl ;\red0\green0\blue255;}
{\info{\horzdoc}{\*\lchars (?[\'7b}{\*\fchars !),.:\'3b?D]\'7d}}
\viewkind4\uc1\pard\ltrpar\nowidctlpar\b\f0\fs20 Application:\b0 NewRoof\line\b Revit Platform:\b0 All\line\b Revit Version:\b0 2011.0\line\b First Released For:\b0 2009.0\line\b Programming Language:\b0 C#\line\b Skill Level:\b0 High\line\b Category:\b0 Elements\line\b Type:\b0 ExternalCommand\line\line\b Subject:\b0 Create footprint and extrusion roof.\line\b Summary:\b0 \line This sample demonstrates four main features:\par
\pard\ltrpar\nowidctlpar\fi-360\li1440\tx1440 1.\tab How to create a new footprint roof.\par
\pard\ltrpar\nowidctlpar\fi-360\li1440 2.\tab How to create an extrusion roof.\par
3.\tab How to edit an existed footprint roof.\par
4.\tab How to edit an existed extrusion roof.\par
\pard\ltrpar\nowidctlpar\par
\b Classes:\b0 \par
\pard\ltrpar\nowidctlpar\fi360 Autodesk.Revit.UI.IExternalCommand\f1\par
\f0 Autodesk.Revit.DB.FootPrintRoof\par
Autodesk.Revit.DB.ExtrusionRoof\par
Autodesk.Revit.DB.Level\par
Autodesk.Revit.DB.RoofType\par
Autodesk.Revit.DB.Wall\par
Autodesk.Revit.DB.Curve\par
Autodesk.Revit.Creation.Document\par
\f1\par
\pard\ltrpar\nowidctlpar\f0\par
\b Project Files:\b0 \par
Command.cs\par
\pard\ltrpar\nowidctlpar\li360\tx720 This file contains the class \ldblquote Command\rdblquote which inherits from \ldblquote IExternalCommand\rdblquote interface and implements the \ldblquote Execute\rdblquote method.\par
\pard\ltrpar\nowidctlpar\fi240\par
\pard\ltrpar\nowidctlpar RoofsManager.cs\f1\par
\pard\ltrpar\nowidctlpar\li360\tx720\f0 It contains a class named \ldblquote RoofsManager\rdblquote which is used to manage the operation between Revit and the Add-In UI. It have the functionalities to create footprint roof, create extrusion roof, select footprint to create footprint roof and select profile to create extrusion roof in Revit.\par
\par
\pard\ltrpar\nowidctlpar FootPrintRoofManager.cs\f1\par
\pard\ltrpar\nowidctlpar\li360\tx720\f0 It contains a class named \ldblquote FootPrintRoofManager\rdblquote which is used to manage the creation of footprint roof.\par
\f1\par
\pard\ltrpar\nowidctlpar\f0 ExtrusionRoofManager.cs\f1\par
\pard\ltrpar\nowidctlpar\li360\tx720\f0 It contains a class named \ldblquote ExtrusionRoofManager\rdblquote which is used to manage creation of extrusion roof.\par
\par
\pard\ltrpar\nowidctlpar RoofForm.cs\f1\par
\pard\ltrpar\nowidctlpar\li360\tx720\f0 It contains a class named \ldblquote RoofForm\rdblquote which is the main UI of the Add-In application. \par
\f1\par
\pard\ltrpar\nowidctlpar\f0 RoofEditorForm.cs\f1\par
\pard\ltrpar\nowidctlpar\li360\tx720\f0 It contains a class named \ldblquote RoofEditorForm\rdblquote which is the edit UI to edit a selected roof in the RoofForm. It contains a PropertyGrid to allow user modify the properties or parameters of the selected roof.\par
\par
\pard\ltrpar\nowidctlpar GraphicsControl.cs\f1\par
\pard\ltrpar\nowidctlpar\li360\tx720\f0 It contains a class named \ldblquote GraphicsControl\rdblquote which is used to display the footprint roof lines in a picture box control when the user is editing a footprint roof. The modifying footprint roof line will be highlighted in the control.\par
\f1\par
\pard\ltrpar\nowidctlpar\f0 CustomTypeConverter.cs\f1\par
\pard\ltrpar\nowidctlpar\li360\tx720\f0 It contains a LevelConverter class and a FootPrintRoofLineConverter class. They are used to custom the display of the some properties in the PropertyGrid control.\par
\par
\pard\ltrpar\nowidctlpar FootPrintRoofWrapper.cs\f1\par
\pard\ltrpar\nowidctlpar\li360\tx720\f0 It contains a FootPrintRoofWrapper class and a FootPrintRoofLine class. The FootPrintRoofWrapper class is used to wrapper a footprint roof to edit the roof in a PropertyGrid control. The FootPrintRoofLine is used to edit the footprint roof line in a PropertyGrid and the line can be drawn in GDI.\par
\f1\par
\pard\ltrpar\nowidctlpar\f0 ExtrusionRoofWrapper.cs\f1\par
\pard\ltrpar\nowidctlpar\li360\tx720\f0 It contains a class named \ldblquote ExtrusionRoofWrapper\rdblquote which is used to wrapper an extrusion roof to edit the roof in a PropertyGrid control.\f1\par
\par
\pard\ltrpar\nowidctlpar\b\f0 Description:\b0 \par
Functionalities:\par
\pard\ltrpar\nowidctlpar\fi-360\li360\tx360 -\tab Get all footprint roofs and extrusion roofs in active document and list them grouped by the creation way.\f1\par
\pard\ltrpar\nowidctlpar\fi-360\li360\f0 -\tab Create a footprint roof with default properties by specifying a curve loop, or a wall loop, or loops combination of walls and curves, a level and a roof type.\f1\par
\f0 -\tab Create an extruded roof by providing a profile which is a series of connected lines or arcs, not closed in a loop, a roof type, a reference plane, an extrusion start value and an extrusion end value\f1 .\f0 Note that the reference plane should be a vertical plane.\par
-\tab Select a footprint roof in the list, then user can define a footprint roof line is slope-defining and can change the slope angel of the selected roof, Also other properties of roof line can be changed respectively, such as overhang, offset from base, extend into wall. The roof\rquote s type can be changed just select a different type\f1 .\par
\f0 -\tab Select an extrusion roof in the list, and then user can change the value of extrusion start, extrusion end, and the roof type and the reference level of the extrusion roof.\f1\par
\pard\ltrpar\nowidctlpar\par
\f0 Implementations:\f1\par
\pard\ltrpar\nowidctlpar\fi-360\li360\tx360\f0 -\tab Using Element Filter to get all kinds roofs.\par
\pard\ltrpar\nowidctlpar\fi-360\li360 -\tab Create footprint roof by the FootPrintRoof NewFootPrintRoof(CurveArray footPrint, Level level, RoofType roofType, ElementIdSet footPrintToModelCurvesMapping) method.\f2 \f0 The footprint can be specified by WindowsSelect() method of Selection class. The roof types can be obtained by the Autodesk.Revit.DB.Document.RoofTypes property.\f1\par
\f0 -\tab Create extrusion roof by the ExtrusionRoof NewExtrusionRoof(CurveArray profile, ReferencePlane refPlane, Level level, RoofType roofType, double extrusionStart, double extrusionEnd) method\f1 .\f0 The profile can be specified by WindowsSelect method and the reference plane should be vertical and can be obtained by using Element filtering functionality\f1\par
\f0 -\tab Edit the footprint roof or extrusion roof by accessing the properties or parameters of the selected roof\f1 .\par
\pard\ltrpar\nowidctlpar\li360\f0\par
\pard\ltrpar\nowidctlpar\b Instructions:\cf1\b0 \cf0\par
\pard\ltrpar\nowidctlpar\fi-360\li360\tx360 1.\tab Open a Revit Architecture 2009 file. A sample project file NewRoof.rvt is available in the sample\rquote s folder.\par
\pard\ltrpar\nowidctlpar\fi-360\li360 2.\tab Draw a curve loop or a wall loop or loops combination of walls and curves to create a footprint roof in Revit. \par
3.\tab Run this command.\par
4.\tab A dialog will be shown to display all the existed roofs. The footprint roofs will be listed in the footprint roof tab page and the extrusion roofs will be listed in the extrusion tab page.\par
5.\tab In the footprint roof tab page, click \ldblquote Select footprint in Revit\rdblquote button to select the footprint you just created. Select a base level and roof type then click the \ldblquote Create\rdblquote button; a footprint roof will be created in Revit and will be listed in the footprint roof tab page. Click \ldblquote OK\rdblquote button to accept the creation or click the \ldblquote Cancel\rdblquote button to abort.\par
6.\tab Draw a series of connected lines or arcs, not closed in a loop to create a profile in Revit. Draw a reference plane in Revit for extrude the profile to create an extrusion roof. Make sure the reference plan is vertical or the extrusion roof will be not creating successfully. If there are many reference planes in Revit, you\rquote d better create a good name for each plane to distinguish them.\par
7.\tab In the extrusion roof tab page, click \ldblquote Select profile in Revit\rdblquote button to select the profile you just created. Select a reference plane, reference level, roof type and specify the extrusion start and extrusion end value, and then click the \ldblquote Create\rdblquote button; an extrusion roof will be created in Revit and will be listed in the extrusion roof tab page. For more information of extrusion start and extrusion end, you\rquote d better refer the extrusion roof part of the help document supplied by Revit. Click \ldblquote OK\rdblquote button to accept the creation or click the \ldblquote Cancel\rdblquote button to abort.\par
8.\tab Edit a footprint roof. You can select a footprint roof and click the \ldblquote Edit\rdblquote button or you just double click the roof in the in the footprint roof tab page; a roof editor form will be displayed. The properties of the roof you can edit in the PropertyGird. The footprint roof lines will be displayed also; the current selected roof line in PropertyGird will be highlighted in red color. You can modify the roof type in the roof type combo box. After the finish the modification you can click the \ldblquote OK\rdblquote button to accept the change or click the \ldblquote Cancel\rdblquote button to abort.\par
9.\tab Edit an extrusion roof. You can select an extrusion roof and click the \ldblquote Edit\rdblquote button or you just double click the roof in the in the extrusion roof tab page; a roof editor form will be displayed. You can edit the parameters of the extrusion roof in the PropertyGird. After the finish the modification you can click the \ldblquote OK\rdblquote button to accept the change or click the \ldblquote Cancel\rdblquote button to abort.\par
\pard\ltrpar\nowidctlpar\f1\fs24\par
}
@@ -0,0 +1,280 @@
//
// (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 System.ComponentModel;
using System.Collections.ObjectModel;
using Autodesk.Revit.DB;
namespace Revit.SDK.Samples.NewRoof.RoofForms.CS
{
/// <summary>
/// The LevelConverter class is inherited from the TypeConverter class which is used to
/// show the property which returns Level type as like a combo box in the PropertyGrid control.
/// </summary>
public class LevelConverter : TypeConverter
{
/// <summary>
/// To store the levels element
/// </summary>
static private Dictionary<String, Level> m_levels = new Dictionary<String, Level>();
/// <summary>
/// Initialize the levels data.
/// </summary>
/// <param name="levels"></param>
static public void SetStandardValues(ReadOnlyCollection<Level> levels)
{
m_levels.Clear();
foreach (Level level in levels)
{
m_levels.Add(level.Id.IntegerValue.ToString(), level);
}
}
/// <summary>
/// Get a level by a level id.
/// </summary>
/// <param name="id">The id of the level</param>
/// <returns>Returns a level which id equals the specified id.</returns>
static public Level GetLevelByID(int id)
{
return m_levels[id.ToString()];
}
/// <summary>
/// Override the CanConvertTo method.
/// </summary>
/// <param name="context"></param>
/// <param name="destinationType"></param>
/// <returns></returns>
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
{
if (destinationType == typeof(Level))
return true;
return base.CanConvertTo(context, destinationType);
}
/// <summary>
/// Override the ConvertTo method, convert a level type value to a string type value for displaying in the PropertyGrid.
/// </summary>
/// <param name="context"></param>
/// <param name="culture"></param>
/// <param name="value"></param>
/// <param name="destinationType"></param>
/// <returns></returns>
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
{
if (destinationType == typeof(String) && value is Level)
{
Level level = (Level)value;
return level.Name + "[" + level.Id.IntegerValue.ToString() + "]";
}
return base.ConvertTo(context, culture, value, destinationType);
}
/// <summary>
/// Override the CanConvertFrom method.
/// </summary>
/// <param name="context"></param>
/// <param name="sourceType"></param>
/// <returns></returns>
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
if (sourceType == typeof(String))
return true;
return base.CanConvertFrom(context, sourceType);
}
/// <summary>
/// Override the ConvertFrom method, convert a string type value to a level type value.
/// </summary>
/// <param name="context"></param>
/// <param name="culture"></param>
/// <param name="value"></param>
/// <returns></returns>
public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
{
if (value is String)
{
try
{
String levelString = (String)value;
int leftBracket = levelString.IndexOf('[');
int rightBracket = levelString.IndexOf(']');
String idString = levelString.Substring(leftBracket + 1, rightBracket - leftBracket - 1);
return m_levels[idString];
}
catch (Exception ex)
{
Autodesk.Revit.UI.TaskDialog.Show("Revit", ex.Message);
}
}
return base.ConvertFrom(context, culture, value);
}
/// <summary>
/// Override the GetStandardValuesSupported method for displaying a level list in the PropertyGrid.
/// </summary>
/// <param name="context"></param>
/// <returns></returns>
public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
{
return true;
}
/// <summary>
/// Override the StandardValuesCollection method for supplying a level list in the PropertyGrid.
/// </summary>
/// <param name="context"></param>
/// <returns></returns>
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
{
return new StandardValuesCollection(m_levels.Values);
}
}
/// <summary>
/// The FootPrintRoofLineConverter class is inherited from the ExpandableObjectConverter class which is used to
/// expand the property which returns FootPrintRoofLine type as like a tree view in the PropertyGrid control.
/// </summary>
public class FootPrintRoofLineConverter : ExpandableObjectConverter
{
// To store the FootPrintRoofLines data.
static private Dictionary<String, FootPrintRoofLine> m_footPrintLines = new Dictionary<String, FootPrintRoofLine>();
/// <summary>
/// Initialize the FootPrintRoofLines data.
/// </summary>
/// <param name="footPrintRoofLines"></param>
static public void SetStandardValues(List<FootPrintRoofLine> footPrintRoofLines)
{
m_footPrintLines.Clear();
foreach (FootPrintRoofLine footPrintLine in footPrintRoofLines)
{
if (m_footPrintLines.ContainsKey(footPrintLine.Id.ToString()))
continue;
m_footPrintLines.Add(footPrintLine.Id.ToString(), footPrintLine);
}
}
/// <summary>
/// Override the CanConvertTo method.
/// </summary>
/// <param name="context"></param>
/// <param name="sourceType"></param>
/// <returns></returns>
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
{
if (destinationType == typeof(FootPrintRoofLine))
return true;
return base.CanConvertTo(context, destinationType);
}
/// <summary>
/// Override the ConvertTo method, convert a FootPrintRoofLine type value to a string type value for displaying in the PropertyGrid.
/// </summary>
/// <param name="context"></param>
/// <param name="culture"></param>
/// <param name="value"></param>
/// <param name="destinationType"></param>
/// <returns></returns>
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
{
if (destinationType == typeof(System.String) && value is FootPrintRoofLine)
{
FootPrintRoofLine footPrintLine = (FootPrintRoofLine)value;
return footPrintLine.Name + "[" + footPrintLine.Id.ToString() + "]";
}
return base.ConvertTo(context, culture, value, destinationType);
}
/// <summary>
/// Override the CanConvertFrom method.
/// </summary>
/// <param name="context"></param>
/// <param name="sourceType"></param>
/// <returns></returns>
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
if (sourceType == typeof(string))
return true;
return base.CanConvertFrom(context, sourceType);
}
/// <summary>
/// Override the ConvertFrom method, convert a string type value to a FootPrintRoofLine type value.
/// </summary>
/// <param name="context"></param>
/// <param name="culture"></param>
/// <param name="value"></param>
/// <returns></returns>
public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
{
if (value is String)
{
try
{
String footPrintLineString = (String)value;
int leftBracket = footPrintLineString.IndexOf('[');
int rightBracket = footPrintLineString.IndexOf(']');
String idString = footPrintLineString.Substring(leftBracket + 1, rightBracket - leftBracket - 1);
return m_footPrintLines[idString];
}
catch (Exception ex)
{
Autodesk.Revit.UI.TaskDialog.Show("Revit", ex.Message);
}
}
return base.ConvertFrom(context, culture, value);
}
/// <summary>
/// Override the GetStandardValuesSupported method for displaying a FootPrintRoofLine list in the PropertyGrid.
/// </summary>
/// <param name="context"></param>
/// <returns></returns>
public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
{
return true;
}
/// <summary>
/// Override the StandardValuesCollection method for supplying a FootPrintRoofLine list in the PropertyGrid.
/// </summary>
/// <param name="context"></param>
/// <returns></returns>
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
{
return new StandardValuesCollection(m_footPrintLines.Values);
}
};
}
@@ -0,0 +1,160 @@
//
// (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 System.ComponentModel;
using System.Collections.ObjectModel;
using Autodesk.Revit;
using Autodesk.Revit.DB;
namespace Revit.SDK.Samples.NewRoof.RoofForms.CS
{
/// <summary>
/// The ExtrusionRoofWrapper class is use to edit a extrusion roof in a PropertyGrid.
/// It contains a extrusion roof.
/// </summary>
public class ExtrusionRoofWrapper
{
// To store the extrusion roof which will be edited in a PropertyGrid.
private ExtrusionRoof m_roof;
/// <summary>
/// The construct of the ExtrusionRoofWrapper class.
/// </summary>
/// <param name="roof">The extrusion roof which will be edited in a PropertyGrid.</param>
public ExtrusionRoofWrapper(ExtrusionRoof roof)
{
m_roof = roof;
}
#region The properties will be shown in the PropertyGrid
/// <summary>
/// The reference plane of the extrusion roof.
/// </summary>
[Category("Constrains")]
[Description("The reference plane of the extrusion roof.")]
public String WorkPlane
{
get
{
Parameter para = m_roof.get_Parameter(BuiltInParameter.SKETCH_PLANE_PARAM);
return para.AsString();
}
}
/// <summary>
/// The extrusion start point of the extrusion roof.
/// </summary>
[Category("Constrains")]
[DisplayName("Extrusion Start")]
[Description("The extrusion of a roof can extend in either direction along the reference plane. If the extrusion extends away from the plane, the start and end points are positive values. If the extrusion extends toward the plane, the start and end points are negative.")]
public String ExtrusionStart
{
get
{
Parameter para = m_roof.get_Parameter(BuiltInParameter.EXTRUSION_START_PARAM);
return para.AsValueString();
}
set
{
Parameter para = m_roof.get_Parameter(BuiltInParameter.EXTRUSION_START_PARAM);
if (para.SetValueString(value) == false)
{
throw new Exception("Invalid Input");
}
}
}
/// <summary>
/// The extrusion end point of the extrusion roof.
/// </summary>
[Category("Constrains")]
[DisplayName("Extrusion End")]
[Description("The extrusion of a roof can extend in either direction along the reference plane. If the extrusion extends away from the plane, the start and end points are positive values. If the extrusion extends toward the plane, the start and end points are negative.")]
public String ExtrusionEnd
{
get
{
Parameter para = m_roof.get_Parameter(BuiltInParameter.EXTRUSION_END_PARAM);
return para.AsValueString();
}
set
{
Parameter para = m_roof.get_Parameter(BuiltInParameter.EXTRUSION_END_PARAM);
if (para.SetValueString(value) == false)
{
throw new Exception("Invalid Input");
}
}
}
/// <summary>
/// The reference level of the extrusion roof.
/// </summary>
[TypeConverterAttribute(typeof(LevelConverter)), Category("Constrains")]
[DisplayName("Reference Level")]
[Description("The reference level of the extrusion roof.")]
public Level ReferenceLevel
{
get
{
Parameter para = m_roof.get_Parameter(BuiltInParameter.ROOF_CONSTRAINT_LEVEL_PARAM);
return LevelConverter.GetLevelByID(para.AsElementId().IntegerValue);
}
set
{
// update reference level
Parameter para = m_roof.get_Parameter(BuiltInParameter.ROOF_CONSTRAINT_LEVEL_PARAM);
Autodesk.Revit.DB.ElementId id = new Autodesk.Revit.DB.ElementId(value.Id.IntegerValue);
para.Set(id);
}
}
/// <summary>
/// The offset from the reference level of the extrusion roof.
/// </summary>
[Category("Constrains")]
[DisplayName("Level Offset")]
[Description("The offset from the reference level.")]
public String LevelOffset
{
get
{
Parameter para = m_roof.get_Parameter(BuiltInParameter.ROOF_CONSTRAINT_OFFSET_PARAM);
return para.AsValueString();
}
set
{
Parameter para = m_roof.get_Parameter(BuiltInParameter.ROOF_CONSTRAINT_OFFSET_PARAM);
if (para.SetValueString(value) == false)
{
throw new Exception("Invalid Input");
}
}
}
#endregion
}
}
@@ -0,0 +1,365 @@
//
// (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 System.Drawing;
using System.ComponentModel;
using System.Collections.ObjectModel;
using Autodesk.Revit;
using Autodesk.Revit.DB;
namespace Revit.SDK.Samples.NewRoof.RoofForms.CS
{
/// <summary>
/// The Util class is used to translate Revit coordination to windows coordination.
/// </summary>
public class Util
{
/// <summary>
/// Translate a Revit 3D point to a windows 2D point according the boundingbox.
/// </summary>
/// <param name="pointXYZ">A Revit 3D point</param>
/// <param name="boundingbox">The boundingbox of the roof whose footprint lines will be displayed in GDI.</param>
/// <returns>A windows 2D point.</returns>
static public PointF Translate(Autodesk.Revit.DB.XYZ pointXYZ, BoundingBoxXYZ boundingbox)
{
double centerX = (boundingbox.Min.X + boundingbox.Max.X) / 2;
double centerY = (boundingbox.Min.Y + boundingbox.Max.Y) / 2;
return new PointF((float)(pointXYZ.X - centerX), -(float)(pointXYZ.Y - centerY));
}
};
/// <summary>
/// The FootPrintRoofLine class is used to edit the foot print data of a footprint roof.
/// </summary>
public class FootPrintRoofLine
{
// To store the footprint roof which the foot print data belong to.
private FootPrintRoof m_roof;
// To store the model curve data which the foot print data stand for.
private ModelCurve m_curve;
// To store the boundingbox of the roof
private BoundingBoxXYZ m_boundingbox;
/// <summary>
/// The construct of the FootPrintRoofLine class.
/// </summary>
/// <param name="roof">The footprint roof which the foot print data belong to.</param>
/// <param name="curve">The model curve data which the foot print data stand for.</param>
public FootPrintRoofLine(FootPrintRoof roof, ModelCurve curve)
{
m_roof = roof;
m_curve = curve;
m_boundingbox = m_roof.get_BoundingBox(Revit.SDK.Samples.NewRoof.CS.Command.ActiveView);
}
/// <summary>
/// Draw the footprint line in GDI.
/// </summary>
/// <param name="graphics"></param>
/// <param name="pen"></param>
public void Draw(System.Drawing.Graphics graphics, System.Drawing.Pen pen)
{
Curve curve = m_curve.GeometryCurve;
DrawCurve(graphics, pen, curve);
}
/// <summary>
/// Draw the curve in GDI.
/// </summary>
/// <param name="graphics"></param>
/// <param name="pen"></param>
/// <param name="curve"></param>
private void DrawCurve(Graphics graphics, System.Drawing.Pen pen, Curve curve)
{
List<PointF> poinsts = new List<PointF>();
foreach (Autodesk.Revit.DB.XYZ point in curve.Tessellate())
{
poinsts.Add(Util.Translate(point,m_boundingbox));
}
graphics.DrawCurve(pen, poinsts.ToArray());
}
/// <summary>
/// Get the model curve data which the foot print data stand for.
/// </summary>
[Browsable(false)]
public ModelCurve ModelCurve
{
get
{
return m_curve;
}
}
/// <summary>
/// Get the id value of the model curve.
/// </summary>
[Browsable(false)]
public int Id
{
get
{
return m_curve.Id.IntegerValue;
}
}
/// <summary>
/// Get the name of the model curve.
/// </summary>
[Browsable(false)]
public String Name
{
get
{
return m_curve.Name;
}
}
/// <summary>
/// Get/Set the slope definition of a model curve of the roof.
/// </summary>
[Description("The slope definition of the FootPrintRoof line.")]
public bool DefinesSlope
{
get
{
return m_roof.get_DefinesSlope(m_curve);
}
set
{
m_roof.set_DefinesSlope(m_curve, value);
}
}
/// <summary>
/// Get/Set the slope angle of the FootPrintRoof line..
/// </summary>
[Description("The slope angle of the FootPrintRoof line.")]
public double SlopeAngle
{
get
{
return m_roof.get_SlopeAngle(m_curve);
}
set
{
m_roof.set_SlopeAngle(m_curve, value);
}
}
/// <summary>
/// Get/Set the offset of the FootPrintRoof line.
/// </summary>
[Description("The offset of the FootPrintRoof line.")]
public double Offset
{
get
{
return m_roof.get_Offset(m_curve);
}
set
{
m_roof.set_Offset(m_curve, value);
}
}
/// <summary>
/// Get/Set the overhang value of the FootPrintRoof line if the roof is created by picked wall.
/// </summary>
[Description("The overhang value of the FootPrintRoof line if the roof is created by picked wall.")]
public double Overhang
{
get
{
return m_roof.get_Overhang(m_curve);
}
set
{
m_roof.set_Overhang(m_curve, value);
}
}
/// <summary>
/// Get/Set ExtendIntoWall value whether you want the overhang to be measured from the core of the wall or not.
/// </summary>
[Description("whether you want the overhang to be measured from the core of the wall or not.")]
public bool ExtendIntoWall
{
get
{
return m_roof.get_ExtendIntoWall(m_curve);
}
set
{
m_roof.set_ExtendIntoWall(m_curve, value);
}
}
};
/// <summary>
/// The FootPrintRoofWrapper class is use to edit a footprint roof in a PropertyGrid.
/// It contains a footprint roof.
/// </summary>
public class FootPrintRoofWrapper
{
// To store the footprint roof which will be edited in a PropertyGrid.
private FootPrintRoof m_roof;
// To store the footprint line data of the roof which will be edited.
private FootPrintRoofLine m_footPrintLine;
// To store the footprint lines data of the roof.
private List<FootPrintRoofLine> m_roofLines;
// To store the boundingbox of the roof
private BoundingBoxXYZ m_boundingbox;
public event EventHandler OnFootPrintRoofLineChanged;
/// <summary>
/// The construct of the FootPrintRoofWrapper class.
/// </summary>
/// <param name="roof">The footprint roof which will be edited in a PropertyGrid.</param>
public FootPrintRoofWrapper(FootPrintRoof roof)
{
m_roof = roof;
m_roofLines = new List<FootPrintRoofLine>();
ModelCurveArrArray curveloops = m_roof.GetProfiles();
foreach(ModelCurveArray curveloop in curveloops)
{
foreach(ModelCurve curve in curveloop)
{
m_roofLines.Add(new FootPrintRoofLine(m_roof, curve));
}
}
FootPrintRoofLineConverter.SetStandardValues(m_roofLines);
m_footPrintLine = m_roofLines[0];
m_boundingbox = m_roof.get_BoundingBox(Revit.SDK.Samples.NewRoof.CS.Command.ActiveView);
}
/// <summary>
/// Get the bounding box of the roof.
/// </summary>
[Browsable(false)]
public BoundingBoxXYZ Boundingbox
{
get
{
return m_boundingbox;
}
}
/// <summary>
/// Get/Set the current footprint roof line which will be edited in the PropertyGrid.
/// </summary>
[TypeConverterAttribute(typeof(FootPrintRoofLineConverter)), Category("Footprint Roof Line Information")]
public FootPrintRoofLine FootPrintLine
{
get
{
return m_footPrintLine;
}
set
{
m_footPrintLine = value;
OnFootPrintRoofLineChanged(this, new EventArgs());
}
}
/// <summary>
/// The base level of the footprint roof.
/// </summary>
[TypeConverterAttribute(typeof(LevelConverter)), Category("Constrains")]
[DisplayName("Base Level")]
public Level BaseLevel
{
get
{
Parameter para = m_roof.get_Parameter(BuiltInParameter.ROOF_BASE_LEVEL_PARAM);
return LevelConverter.GetLevelByID(para.AsElementId().IntegerValue);
}
set
{
// update base level
Parameter para = m_roof.get_Parameter(BuiltInParameter.ROOF_BASE_LEVEL_PARAM);
Autodesk.Revit.DB.ElementId id = new Autodesk.Revit.DB.ElementId(value.Id.IntegerValue);
para.Set(id);
}
}
/// <summary>
/// The eave cutter type of the footprint roof.
/// </summary>
[Category("Construction")]
[DisplayName("Rafter Cut")]
[Description("The eave cutter type of the footprint roof.")]
public EaveCutterType EaveCutterType
{
get
{
return m_roof.EaveCuts;
}
set
{
m_roof.EaveCuts = value;
}
}
/// <summary>
/// Get the footprint roof lines data.
/// </summary>
[Browsable(false)]
public ReadOnlyCollection<FootPrintRoofLine> FootPrintRoofLines
{
get
{
return new ReadOnlyCollection<FootPrintRoofLine>(m_roofLines);
}
}
/// <summary>
/// Draw the footprint lines.
/// </summary>
/// <param name="graphics">The graphics object.</param>
/// <param name="displayPen">A display pen.</param>
/// <param name="highlightPen">A highlight pen.</param>
public void DrawFootPrint(Graphics graphics, Pen displayPen, Pen highlightPen)
{
foreach (FootPrintRoofLine line in m_roofLines)
{
if (line.Id == m_footPrintLine.Id)
{
line.Draw(graphics, highlightPen);
}
else
{
line.Draw(graphics, displayPen);
}
}
}
}
}
@@ -0,0 +1,66 @@
// (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.NewRoof.RoofForms.CS
{
partial class GraphicsControl
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <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 Component 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.SuspendLayout();
//
// GraphicsControl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Name = "GraphicsControl";
this.Size = new System.Drawing.Size(151, 146);
this.ResumeLayout(false);
}
#endregion
}
}
@@ -0,0 +1,135 @@
//
// (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.Drawing;
using System.Drawing.Drawing2D;
using System.Data;
using System.Text;
using System.Windows.Forms;
using Autodesk.Revit.DB;
namespace Revit.SDK.Samples.NewRoof.RoofForms.CS
{
/// <summary>
/// The GraphicsControl is used to display the footprint roof lines with GDI.
/// </summary>
public partial class GraphicsControl : UserControl
{
// A reference to FootPrintRoofWrapper, It constrains the DrawFootPrint() method to
// draw footprint roof lines in the PictureBox control.
private FootPrintRoofWrapper m_footPrintRoofWrapper;
// To store a highlight pen to highlight the specified footprint roof line.
private Pen m_highLightPen;
// To store a display pen to draw the footprint roof lines.
private Pen m_displayPen;
// To store the draw center location of the PictureBox control, it is the origin of the drawing.
public PointF m_drawCenter;
// To store a value to decide the scale of the drawing.
private float m_scale;
/// <summary>
/// The private construct
/// </summary>
private GraphicsControl()
{
InitializeComponent();
}
/// <summary>
/// The construct of the GraphicsControl.
/// </summary>
/// <param name="footPrintRoofWrapper">A reference to FootPrintRoofWrapper which will be displayed in
/// the picture box control.</param>
public GraphicsControl(FootPrintRoofWrapper footPrintRoofWrapper)
{
InitializeComponent();
this.Load += new EventHandler(GraphicsControl_Load);
m_displayPen = new Pen(System.Drawing.Color.Green, 0);
m_highLightPen = new Pen(System.Drawing.Color.Red, 0);
m_footPrintRoofWrapper = footPrintRoofWrapper;
}
/// <summary>
/// When the GraphicsControl was loaded, then add the picture box control to it
/// and initialize the draw center and scale value.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void GraphicsControl_Load(object sender, EventArgs e)
{
PictureBox picturebox = new PictureBox();
picturebox.Dock = DockStyle.Fill;
this.Controls.Add(picturebox);
picturebox.Paint += new PaintEventHandler(picturebox_Paint);
// initialize the draw center and scale value
m_drawCenter = new PointF(picturebox.Size.Width / 2, picturebox.Size.Height / 2);
Autodesk.Revit.DB.XYZ size = m_footPrintRoofWrapper.Boundingbox.Max - m_footPrintRoofWrapper.Boundingbox.Min;
float tempscale1 = (float)((0.9 * picturebox.Width) / size.X);
float tempscale2 = (float)((0.9 * picturebox.Height) / size.Y);
if (tempscale1 > tempscale2)
{
m_scale = tempscale2;
}
else
{
m_scale = tempscale1;
}
// Book the OnFootPrintRoofLineChanged event to refresh the picture box
m_footPrintRoofWrapper.OnFootPrintRoofLineChanged += new EventHandler(m_footPrintRoofWrapper_OnFootPrintRoofLineChanged);
}
/// <summary>
/// When the current selected FootPrintRoofLine changed in the PropertyGrid, then update the drawing.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void m_footPrintRoofWrapper_OnFootPrintRoofLineChanged(object sender, EventArgs e)
{
this.Refresh();
}
/// <summary>
/// Display the footprint roof lines in the picture box control.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void picturebox_Paint(object sender, PaintEventArgs e)
{
Graphics graphics = e.Graphics;
graphics.Clear(System.Drawing.Color.White);
graphics.TranslateTransform(m_drawCenter.X, m_drawCenter.Y);
graphics.ScaleTransform(m_scale, m_scale);
graphics.PageUnit = GraphicsUnit.Pixel;
m_footPrintRoofWrapper.DrawFootPrint(graphics, m_displayPen, m_highLightPen);
}
}
}
@@ -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,154 @@
//
// (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.NewRoof.RoofForms.CS
{
partial class RoofEditorForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <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.roofEditorPropertyGrid = new System.Windows.Forms.PropertyGrid();
this.label1 = new System.Windows.Forms.Label();
this.roofTypesComboBox = new System.Windows.Forms.ComboBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.okButton = new System.Windows.Forms.Button();
this.cancelButton = new System.Windows.Forms.Button();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// roofEditorPropertyGrid
//
this.roofEditorPropertyGrid.Location = new System.Drawing.Point(6, 19);
this.roofEditorPropertyGrid.Name = "roofEditorPropertyGrid";
this.roofEditorPropertyGrid.Size = new System.Drawing.Size(365, 385);
this.roofEditorPropertyGrid.TabIndex = 0;
this.roofEditorPropertyGrid.ToolbarVisible = false;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(9, 12);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(60, 13);
this.label1.TabIndex = 1;
this.label1.Text = "Roof Type:";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// roofTypesComboBox
//
this.roofTypesComboBox.FormattingEnabled = true;
this.roofTypesComboBox.Location = new System.Drawing.Point(75, 9);
this.roofTypesComboBox.Name = "roofTypesComboBox";
this.roofTypesComboBox.Size = new System.Drawing.Size(314, 21);
this.roofTypesComboBox.TabIndex = 2;
//
// groupBox1
//
this.groupBox1.Controls.Add(this.roofEditorPropertyGrid);
this.groupBox1.Location = new System.Drawing.Point(12, 36);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(377, 410);
this.groupBox1.TabIndex = 3;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Roof Properties";
//
// okButton
//
this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
this.okButton.Location = new System.Drawing.Point(233, 452);
this.okButton.Name = "okButton";
this.okButton.Size = new System.Drawing.Size(75, 23);
this.okButton.TabIndex = 4;
this.okButton.Text = "&OK";
this.okButton.UseVisualStyleBackColor = true;
this.okButton.Click += new System.EventHandler(this.okButton_Click);
//
// cancelButton
//
this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.cancelButton.Location = new System.Drawing.Point(314, 452);
this.cancelButton.Name = "cancelButton";
this.cancelButton.Size = new System.Drawing.Size(75, 23);
this.cancelButton.TabIndex = 5;
this.cancelButton.Text = "&Cancel";
this.cancelButton.UseVisualStyleBackColor = true;
//
// RoofEditorForm
//
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(401, 487);
this.Controls.Add(this.cancelButton);
this.Controls.Add(this.okButton);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.roofTypesComboBox);
this.Controls.Add(this.label1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "RoofEditorForm";
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Roof Editor";
this.Load += new System.EventHandler(this.RoofEditorForm_Load);
this.groupBox1.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.PropertyGrid roofEditorPropertyGrid;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ComboBox roofTypesComboBox;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Button okButton;
private System.Windows.Forms.Button cancelButton;
}
}
@@ -0,0 +1,130 @@
//
// (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.DB;
namespace Revit.SDK.Samples.NewRoof.RoofForms.CS
{
/// <summary>
/// The RoofEditorForm is the main edit form to edit a roof data.
/// </summary>
public partial class RoofEditorForm : System.Windows.Forms.Form
{
// To store the roof which will be edited.
private RoofBase m_roof;
// A reference to the roofs manager
private RoofsManager.CS.RoofsManager m_roofsManager;
// To store the FootPrintRoofWrapper data of the roof.
private FootPrintRoofWrapper m_footPrintRoofWrapper;
// To store the ExtrusionRoofWrapper data of the roof.
private ExtrusionRoofWrapper m_extrusionRoofWrapper;
// A GraphicsControl to display the roof lines of footprint roof.
private GraphicsControl m_graphicsControl;
/// <summary>
/// The private construct.
/// </summary>
private RoofEditorForm()
{
InitializeComponent();
}
/// <summary>
/// The construct of the RoofEditorForm class.
/// </summary>
/// <param name="roofsManager">A reference to the roofs manager</param>
/// <param name="roof">The roof which will be edited.</param>
public RoofEditorForm(RoofsManager.CS.RoofsManager roofsManager, RoofBase roof)
{
m_roofsManager = roofsManager;
m_roof = roof;
InitializeComponent();
m_footPrintRoofWrapper = null;
m_extrusionRoofWrapper = null;
if (m_roof is FootPrintRoof)
{
m_footPrintRoofWrapper = new FootPrintRoofWrapper(m_roof as FootPrintRoof);
}
else
{
m_extrusionRoofWrapper = new ExtrusionRoofWrapper(m_roof as ExtrusionRoof);
}
}
/// <summary>
/// When the RoofEditorForm was loaded, then initialize data of the controls in the form.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void RoofEditorForm_Load(object sender, EventArgs e)
{
this.roofTypesComboBox.DataSource = m_roofsManager.RoofTypes;
this.roofTypesComboBox.DisplayMember = "Name";
this.roofTypesComboBox.ValueMember = "Id";
this.roofTypesComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
this.roofTypesComboBox.SelectedValue = m_roof.RoofType.Id;
if (m_roof is FootPrintRoof)
{
this.roofEditorPropertyGrid.SelectedObject = m_footPrintRoofWrapper;
this.Size = new Size(814, 515);
Label label = new Label();
label.Text = "Footprint roof lines:";
label.AutoSize = true;
label.Location = new System.Drawing.Point(398, 12);
this.Controls.Add(label);
m_graphicsControl = new GraphicsControl(m_footPrintRoofWrapper);
m_graphicsControl.Location = new System.Drawing.Point(398, 36);
m_graphicsControl.Size = new Size(400, 440);
this.Controls.Add(m_graphicsControl);
}
else
{
this.roofEditorPropertyGrid.SelectedObject = m_extrusionRoofWrapper;
}
this.roofEditorPropertyGrid.ExpandAllGridItems();
}
/// <summary>
/// When the OK button was clicked, update the roof type of the editing roof.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void okButton_Click(object sender, EventArgs e)
{
m_roof.RoofType = this.roofTypesComboBox.SelectedItem as Autodesk.Revit.DB.RoofType;
}
}
}
@@ -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>
+514
View File
@@ -0,0 +1,514 @@
//
// (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.NewRoof.RoofForms.CS
{
partial class RoofForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <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.footPrintRoofsListView = new System.Windows.Forms.ListView();
this.columnHeader1 = new System.Windows.Forms.ColumnHeader();
this.columnHeader2 = new System.Windows.Forms.ColumnHeader();
this.columnHeader3 = new System.Windows.Forms.ColumnHeader();
this.columnHeader4 = new System.Windows.Forms.ColumnHeader();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.roofsTabControl = new System.Windows.Forms.TabControl();
this.footprintRoofTabPage = new System.Windows.Forms.TabPage();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.roofTypesComboBox = new System.Windows.Forms.ComboBox();
this.label3 = new System.Windows.Forms.Label();
this.levelsComboBox = new System.Windows.Forms.ComboBox();
this.levelLabel = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.selectFootPrintButton = new System.Windows.Forms.Button();
this.extrusionRoofTabPage = new System.Windows.Forms.TabPage();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.extrusionEndTextBox = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.extrusionStartTextBox = new System.Windows.Forms.TextBox();
this.refPanesComboBox = new System.Windows.Forms.ComboBox();
this.label2 = new System.Windows.Forms.Label();
this.extrusionRoofTypesComboBox = new System.Windows.Forms.ComboBox();
this.label6 = new System.Windows.Forms.Label();
this.refLevelComboBox = new System.Windows.Forms.ComboBox();
this.label7 = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label();
this.selectProfileButton = new System.Windows.Forms.Button();
this.extrusionRoofsListView = new System.Windows.Forms.ListView();
this.columnHeader5 = new System.Windows.Forms.ColumnHeader();
this.columnHeader6 = new System.Windows.Forms.ColumnHeader();
this.columnHeader7 = new System.Windows.Forms.ColumnHeader();
this.columnHeader8 = new System.Windows.Forms.ColumnHeader();
this.editRoofButton = new System.Windows.Forms.Button();
this.createRoofButton = new System.Windows.Forms.Button();
this.okButton = new System.Windows.Forms.Button();
this.cancelButton = new System.Windows.Forms.Button();
this.groupBox1.SuspendLayout();
this.roofsTabControl.SuspendLayout();
this.footprintRoofTabPage.SuspendLayout();
this.groupBox2.SuspendLayout();
this.extrusionRoofTabPage.SuspendLayout();
this.groupBox3.SuspendLayout();
this.SuspendLayout();
//
// footPrintRoofsListView
//
this.footPrintRoofsListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1,
this.columnHeader2,
this.columnHeader3,
this.columnHeader4});
this.footPrintRoofsListView.Location = new System.Drawing.Point(3, 6);
this.footPrintRoofsListView.Name = "footPrintRoofsListView";
this.footPrintRoofsListView.Size = new System.Drawing.Size(368, 231);
this.footPrintRoofsListView.TabIndex = 2;
this.footPrintRoofsListView.UseCompatibleStateImageBehavior = false;
this.footPrintRoofsListView.View = System.Windows.Forms.View.Details;
//
// columnHeader1
//
this.columnHeader1.Text = "Roof Id";
//
// columnHeader2
//
this.columnHeader2.Text = "Name";
//
// columnHeader3
//
this.columnHeader3.Text = "Base Level";
//
// columnHeader4
//
this.columnHeader4.Text = "Roof Type";
//
// groupBox1
//
this.groupBox1.Controls.Add(this.roofsTabControl);
this.groupBox1.Controls.Add(this.editRoofButton);
this.groupBox1.Controls.Add(this.createRoofButton);
this.groupBox1.Location = new System.Drawing.Point(2, 2);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(395, 447);
this.groupBox1.TabIndex = 3;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Roofs";
//
// roofsTabControl
//
this.roofsTabControl.Controls.Add(this.footprintRoofTabPage);
this.roofsTabControl.Controls.Add(this.extrusionRoofTabPage);
this.roofsTabControl.Location = new System.Drawing.Point(6, 19);
this.roofsTabControl.Name = "roofsTabControl";
this.roofsTabControl.SelectedIndex = 0;
this.roofsTabControl.Size = new System.Drawing.Size(382, 383);
this.roofsTabControl.TabIndex = 5;
//
// footprintRoofTabPage
//
this.footprintRoofTabPage.Controls.Add(this.groupBox2);
this.footprintRoofTabPage.Controls.Add(this.footPrintRoofsListView);
this.footprintRoofTabPage.Location = new System.Drawing.Point(4, 22);
this.footprintRoofTabPage.Name = "footprintRoofTabPage";
this.footprintRoofTabPage.Padding = new System.Windows.Forms.Padding(3);
this.footprintRoofTabPage.Size = new System.Drawing.Size(374, 357);
this.footprintRoofTabPage.TabIndex = 0;
this.footprintRoofTabPage.Text = "Footprint Roofs";
this.footprintRoofTabPage.UseVisualStyleBackColor = true;
//
// groupBox2
//
this.groupBox2.Controls.Add(this.roofTypesComboBox);
this.groupBox2.Controls.Add(this.label3);
this.groupBox2.Controls.Add(this.levelsComboBox);
this.groupBox2.Controls.Add(this.levelLabel);
this.groupBox2.Controls.Add(this.label1);
this.groupBox2.Controls.Add(this.selectFootPrintButton);
this.groupBox2.Location = new System.Drawing.Point(6, 243);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(365, 108);
this.groupBox2.TabIndex = 3;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Create FootPrintRoof";
//
// roofTypesComboBox
//
this.roofTypesComboBox.FormattingEnabled = true;
this.roofTypesComboBox.Location = new System.Drawing.Point(64, 73);
this.roofTypesComboBox.Name = "roofTypesComboBox";
this.roofTypesComboBox.Size = new System.Drawing.Size(295, 21);
this.roofTypesComboBox.TabIndex = 6;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(6, 76);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(60, 13);
this.label3.TabIndex = 5;
this.label3.Text = "Roof Type:";
//
// levelsComboBox
//
this.levelsComboBox.FormattingEnabled = true;
this.levelsComboBox.Location = new System.Drawing.Point(64, 46);
this.levelsComboBox.Name = "levelsComboBox";
this.levelsComboBox.Size = new System.Drawing.Size(295, 21);
this.levelsComboBox.TabIndex = 4;
//
// levelLabel
//
this.levelLabel.AutoSize = true;
this.levelLabel.Location = new System.Drawing.Point(6, 49);
this.levelLabel.Name = "levelLabel";
this.levelLabel.Size = new System.Drawing.Size(36, 13);
this.levelLabel.TabIndex = 3;
this.levelLabel.Text = "Level:";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(6, 22);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(51, 13);
this.label1.TabIndex = 2;
this.label1.Text = "Footprint:";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// selectFootPrintButton
//
this.selectFootPrintButton.DialogResult = System.Windows.Forms.DialogResult.Retry;
this.selectFootPrintButton.Location = new System.Drawing.Point(64, 17);
this.selectFootPrintButton.Name = "selectFootPrintButton";
this.selectFootPrintButton.Size = new System.Drawing.Size(295, 23);
this.selectFootPrintButton.TabIndex = 1;
this.selectFootPrintButton.Text = "&Select Footprint in Revit";
this.selectFootPrintButton.UseVisualStyleBackColor = true;
//
// extrusionRoofTabPage
//
this.extrusionRoofTabPage.Controls.Add(this.groupBox3);
this.extrusionRoofTabPage.Controls.Add(this.extrusionRoofsListView);
this.extrusionRoofTabPage.Location = new System.Drawing.Point(4, 22);
this.extrusionRoofTabPage.Name = "extrusionRoofTabPage";
this.extrusionRoofTabPage.Padding = new System.Windows.Forms.Padding(3);
this.extrusionRoofTabPage.Size = new System.Drawing.Size(374, 357);
this.extrusionRoofTabPage.TabIndex = 1;
this.extrusionRoofTabPage.Text = "Extrusion Roofs";
this.extrusionRoofTabPage.UseVisualStyleBackColor = true;
//
// groupBox3
//
this.groupBox3.Controls.Add(this.extrusionEndTextBox);
this.groupBox3.Controls.Add(this.label5);
this.groupBox3.Controls.Add(this.label4);
this.groupBox3.Controls.Add(this.extrusionStartTextBox);
this.groupBox3.Controls.Add(this.refPanesComboBox);
this.groupBox3.Controls.Add(this.label2);
this.groupBox3.Controls.Add(this.extrusionRoofTypesComboBox);
this.groupBox3.Controls.Add(this.label6);
this.groupBox3.Controls.Add(this.refLevelComboBox);
this.groupBox3.Controls.Add(this.label7);
this.groupBox3.Controls.Add(this.label8);
this.groupBox3.Controls.Add(this.selectProfileButton);
this.groupBox3.Location = new System.Drawing.Point(3, 207);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(368, 154);
this.groupBox3.TabIndex = 4;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "Create ExtrusionRoof";
//
// extrusionEndTextBox
//
this.extrusionEndTextBox.Location = new System.Drawing.Point(285, 123);
this.extrusionEndTextBox.Name = "extrusionEndTextBox";
this.extrusionEndTextBox.Size = new System.Drawing.Size(77, 20);
this.extrusionEndTextBox.TabIndex = 12;
this.extrusionEndTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.extrusionEndTextBox_Validating);
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(207, 126);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(75, 13);
this.label5.TabIndex = 11;
this.label5.Text = "Extrusion End:";
this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(6, 126);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(78, 13);
this.label4.TabIndex = 10;
this.label4.Text = "Extrusion Start:";
this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// extrusionStartTextBox
//
this.extrusionStartTextBox.Location = new System.Drawing.Point(84, 124);
this.extrusionStartTextBox.Name = "extrusionStartTextBox";
this.extrusionStartTextBox.Size = new System.Drawing.Size(74, 20);
this.extrusionStartTextBox.TabIndex = 9;
this.extrusionStartTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.extrusionStartTextBox_Validating);
//
// refPanesComboBox
//
this.refPanesComboBox.FormattingEnabled = true;
this.refPanesComboBox.Location = new System.Drawing.Point(84, 45);
this.refPanesComboBox.Name = "refPanesComboBox";
this.refPanesComboBox.Size = new System.Drawing.Size(278, 21);
this.refPanesComboBox.TabIndex = 8;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(6, 48);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(57, 13);
this.label2.TabIndex = 7;
this.label2.Text = "Ref Plane:";
//
// extrusionRoofTypesComboBox
//
this.extrusionRoofTypesComboBox.FormattingEnabled = true;
this.extrusionRoofTypesComboBox.Location = new System.Drawing.Point(84, 97);
this.extrusionRoofTypesComboBox.Name = "extrusionRoofTypesComboBox";
this.extrusionRoofTypesComboBox.Size = new System.Drawing.Size(278, 21);
this.extrusionRoofTypesComboBox.TabIndex = 6;
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(6, 100);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(60, 13);
this.label6.TabIndex = 5;
this.label6.Text = "Roof Type:";
//
// refLevelComboBox
//
this.refLevelComboBox.FormattingEnabled = true;
this.refLevelComboBox.Location = new System.Drawing.Point(84, 71);
this.refLevelComboBox.Name = "refLevelComboBox";
this.refLevelComboBox.Size = new System.Drawing.Size(278, 21);
this.refLevelComboBox.TabIndex = 4;
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(6, 74);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(56, 13);
this.label7.TabIndex = 3;
this.label7.Text = "Ref Level:";
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(6, 22);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(39, 13);
this.label8.TabIndex = 2;
this.label8.Text = "Profile:";
this.label8.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// selectProfileButton
//
this.selectProfileButton.DialogResult = System.Windows.Forms.DialogResult.Retry;
this.selectProfileButton.Location = new System.Drawing.Point(84, 17);
this.selectProfileButton.Name = "selectProfileButton";
this.selectProfileButton.Size = new System.Drawing.Size(263, 23);
this.selectProfileButton.TabIndex = 1;
this.selectProfileButton.Text = "&Select Profile in Revit";
this.selectProfileButton.UseVisualStyleBackColor = true;
//
// extrusionRoofsListView
//
this.extrusionRoofsListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader5,
this.columnHeader6,
this.columnHeader7,
this.columnHeader8});
this.extrusionRoofsListView.Location = new System.Drawing.Point(3, 6);
this.extrusionRoofsListView.Name = "extrusionRoofsListView";
this.extrusionRoofsListView.Size = new System.Drawing.Size(368, 197);
this.extrusionRoofsListView.TabIndex = 3;
this.extrusionRoofsListView.UseCompatibleStateImageBehavior = false;
this.extrusionRoofsListView.View = System.Windows.Forms.View.Details;
//
// columnHeader5
//
this.columnHeader5.Text = "Roof Id";
//
// columnHeader6
//
this.columnHeader6.Text = "Name";
//
// columnHeader7
//
this.columnHeader7.Text = "Reference Level";
this.columnHeader7.Width = 102;
//
// columnHeader8
//
this.columnHeader8.Text = "Roof Type";
//
// editRoofButton
//
this.editRoofButton.Location = new System.Drawing.Point(207, 408);
this.editRoofButton.Name = "editRoofButton";
this.editRoofButton.Size = new System.Drawing.Size(181, 23);
this.editRoofButton.TabIndex = 4;
this.editRoofButton.Text = "Edit";
this.editRoofButton.UseVisualStyleBackColor = true;
this.editRoofButton.Click += new System.EventHandler(this.editRoofButton_Click);
//
// createRoofButton
//
this.createRoofButton.Location = new System.Drawing.Point(6, 408);
this.createRoofButton.Name = "createRoofButton";
this.createRoofButton.Size = new System.Drawing.Size(181, 23);
this.createRoofButton.TabIndex = 3;
this.createRoofButton.Text = "Create";
this.createRoofButton.UseVisualStyleBackColor = true;
this.createRoofButton.Click += new System.EventHandler(this.createRoofButton_Click);
//
// okButton
//
this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
this.okButton.Location = new System.Drawing.Point(240, 455);
this.okButton.Name = "okButton";
this.okButton.Size = new System.Drawing.Size(75, 23);
this.okButton.TabIndex = 4;
this.okButton.Text = "&OK";
this.okButton.UseVisualStyleBackColor = true;
//
// cancelButton
//
this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.cancelButton.Location = new System.Drawing.Point(322, 455);
this.cancelButton.Name = "cancelButton";
this.cancelButton.Size = new System.Drawing.Size(75, 23);
this.cancelButton.TabIndex = 5;
this.cancelButton.Text = "&Cancel";
this.cancelButton.UseVisualStyleBackColor = true;
//
// RoofForm
//
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(401, 487);
this.Controls.Add(this.cancelButton);
this.Controls.Add(this.okButton);
this.Controls.Add(this.groupBox1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "RoofForm";
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "New Roof";
this.Load += new System.EventHandler(this.RoofForm_Load);
this.groupBox1.ResumeLayout(false);
this.roofsTabControl.ResumeLayout(false);
this.footprintRoofTabPage.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.extrusionRoofTabPage.ResumeLayout(false);
this.groupBox3.ResumeLayout(false);
this.groupBox3.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.ListView footPrintRoofsListView;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Button okButton;
private System.Windows.Forms.Button cancelButton;
private System.Windows.Forms.Button editRoofButton;
private System.Windows.Forms.Button createRoofButton;
private System.Windows.Forms.TabControl roofsTabControl;
private System.Windows.Forms.TabPage footprintRoofTabPage;
private System.Windows.Forms.TabPage extrusionRoofTabPage;
private System.Windows.Forms.ListView extrusionRoofsListView;
private System.Windows.Forms.ColumnHeader columnHeader1;
private System.Windows.Forms.ColumnHeader columnHeader2;
private System.Windows.Forms.ColumnHeader columnHeader3;
private System.Windows.Forms.ColumnHeader columnHeader4;
private System.Windows.Forms.ColumnHeader columnHeader5;
private System.Windows.Forms.ColumnHeader columnHeader6;
private System.Windows.Forms.ColumnHeader columnHeader7;
private System.Windows.Forms.ColumnHeader columnHeader8;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.ComboBox roofTypesComboBox;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.ComboBox levelsComboBox;
private System.Windows.Forms.Label levelLabel;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button selectFootPrintButton;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.TextBox extrusionEndTextBox;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox extrusionStartTextBox;
private System.Windows.Forms.ComboBox refPanesComboBox;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.ComboBox extrusionRoofTypesComboBox;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.ComboBox refLevelComboBox;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.Button selectProfileButton;
}
}
@@ -0,0 +1,382 @@
//
// (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.DB;
using Autodesk.Revit.UI;
namespace Revit.SDK.Samples.NewRoof.RoofForms.CS
{
/// <summary>
/// The main form to create or delete roof in Revit.
/// </summary>
public partial class RoofForm : System.Windows.Forms.Form
{
// A reference to the roofs manager
private RoofsManager.CS.RoofsManager m_roofsManager;
// To store the extrusion start and extrusion end value for creating extrusion roof.
private double m_start, m_end;
/// <summary>
/// The private construct.
/// </summary>
private RoofForm()
{
InitializeComponent();
}
/// <summary>
/// The construct of the RoofForm class.
/// </summary>
/// <param name="roofsManager">A reference to the roofs manager</param>
public RoofForm(RoofsManager.CS.RoofsManager roofsManager)
{
m_roofsManager = roofsManager;
m_start = -10.0;
m_end = 10.0;
InitializeComponent();
}
/// <summary>
/// When the RoofForm was loaded, then initialize data of the controls in the form.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void RoofForm_Load(object sender, EventArgs e)
{
foreach (FootPrintRoof roof in m_roofsManager.FootPrintRoofs)
{
this.footPrintRoofsListView.Items.Add(new RoofItem(roof));
}
foreach (ExtrusionRoof roof in m_roofsManager.ExtrusionRoofs)
{
this.extrusionRoofsListView.Items.Add(new RoofItem(roof));
}
this.levelsComboBox.DataSource = m_roofsManager.Levels;
this.levelsComboBox.DisplayMember = "Name";
this.levelsComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
this.roofTypesComboBox.DataSource = m_roofsManager.RoofTypes;
this.roofTypesComboBox.DisplayMember = "Name";
this.roofTypesComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
this.refLevelComboBox.DataSource = m_roofsManager.Levels;
this.refLevelComboBox.DisplayMember = "Name";
this.refLevelComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
this.extrusionRoofTypesComboBox.DataSource = m_roofsManager.RoofTypes;
this.extrusionRoofTypesComboBox.DisplayMember = "Name";
this.extrusionRoofTypesComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
this.refPanesComboBox.DataSource = m_roofsManager.ReferencePlanes;
this.refPanesComboBox.DisplayMember = "Name";
this.refPanesComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
// Book Select Button Click Event
this.selectFootPrintButton.Click += new EventHandler(selectFootPrintButton_Click);
this.selectProfileButton.Click += new EventHandler(selectProfileButton_Click);
if (m_roofsManager.RoofKind == Revit.SDK.Samples.NewRoof.RoofsManager.CS.CreateRoofKind.FootPrintRoof)
{
this.roofsTabControl.SelectedTab = this.footprintRoofTabPage;
}
else
{
this.roofsTabControl.SelectedTab = this.extrusionRoofTabPage;
}
this.footPrintRoofsListView.MultiSelect = false;
this.footPrintRoofsListView.FullRowSelect = true;
this.footPrintRoofsListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
this.footPrintRoofsListView.MouseDoubleClick += new MouseEventHandler(roofsListView_MouseDoubleClick);
this.extrusionRoofsListView.MultiSelect = false;
this.extrusionRoofsListView.FullRowSelect = true;
this.extrusionRoofsListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
this.extrusionRoofsListView.MouseDoubleClick += new MouseEventHandler(roofsListView_MouseDoubleClick);
this.extrusionStartTextBox.Text = m_start.ToString();
this.extrusionEndTextBox.Text = m_end.ToString();
}
/// <summary>
/// When selectFootPrintButton was clicked, then select some footprint loops in Revit.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void selectFootPrintButton_Click(object sender, EventArgs e)
{
this.m_roofsManager.RoofKind = Revit.SDK.Samples.NewRoof.RoofsManager.CS.CreateRoofKind.FootPrintRoof;
this.Close();
}
/// <summary>
/// When selectFootPrintButton was clicked, then select profile in Revit.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void selectProfileButton_Click(object sender, EventArgs e)
{
this.m_roofsManager.RoofKind = Revit.SDK.Samples.NewRoof.RoofsManager.CS.CreateRoofKind.ExtrusionRoof;
this.Close();
}
/// <summary>
/// when createRoofButton was clicked, then create a new roof.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void createRoofButton_Click(object sender, EventArgs e)
{
if (this.roofsTabControl.SelectedTab == this.footprintRoofTabPage)
{
createFootPrintRoof();
}
else
{
createExtrusionRoof();
}
}
/// <summary>
/// When editRoofButton was click, then create a new RoofEditorForm to edit the selected roof.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void editRoofButton_Click(object sender, EventArgs e)
{
if (this.footPrintRoofsListView.SelectedItems.Count != 0
|| this.extrusionRoofsListView.SelectedItems.Count != 0)
{
RoofItem item = null;
if (this.roofsTabControl.SelectedTab == this.footprintRoofTabPage)
{
item = this.footPrintRoofsListView.SelectedItems[0] as RoofItem;
}
else
{
item = this.extrusionRoofsListView.SelectedItems[0] as RoofItem;
}
if (item != null)
{
EditRoofItem(item.ListView, item);
}
}
else
{
TaskDialog.Show("Revit", "To edit a roof, you should select a roof or double click a roof in the list first.");
}
}
/// <summary>
/// Create a new footprint roof.
/// </summary>
private void createFootPrintRoof()
{
try
{
if (m_roofsManager.FootPrint.Size != 0)
{
Autodesk.Revit.DB.Level level = levelsComboBox.SelectedItem as Autodesk.Revit.DB.Level;
Autodesk.Revit.DB.RoofType roofType = roofTypesComboBox.SelectedItem as Autodesk.Revit.DB.RoofType;
if (level != null && roofType != null)
{
Autodesk.Revit.DB.FootPrintRoof roof = m_roofsManager.CreateFootPrintRoof(level, roofType);
if (roof == null)
{
TaskDialog.Show("Revit", "Invalid footprint2");
}
else
{
this.footPrintRoofsListView.Items.Add(new RoofItem(roof));
this.footPrintRoofsListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
}
}
}
else
{
TaskDialog.Show("Revit", "You should supply footprint to create footprint roof, click select button to select footprint in Revit.");
}
}
catch (Exception ex)
{
TaskDialog.Show("Revit", ex.Message + " : Footprint must be in closed loops.");
}
}
/// <summary>
/// Create a extrusion roof.
/// </summary>
private void createExtrusionRoof()
{
try
{
if (m_roofsManager.Profile.Size != 0)
{
Autodesk.Revit.DB.Level level = this.refLevelComboBox.SelectedItem as Autodesk.Revit.DB.Level;
Autodesk.Revit.DB.RoofType roofType = this.extrusionRoofTypesComboBox.SelectedItem as Autodesk.Revit.DB.RoofType;
Autodesk.Revit.DB.ReferencePlane refPlane = refPanesComboBox.SelectedItem as Autodesk.Revit.DB.ReferencePlane;
if (level != null && roofType != null && refPlane != null)
{
Autodesk.Revit.DB.ExtrusionRoof roof = m_roofsManager.CreateExtrusionRoof(refPlane, level, roofType, m_start, m_end);
if (roof == null)
{
TaskDialog.Show("Revit", "Invalid profile");
}
else
{
this.extrusionRoofsListView.Items.Add(new RoofItem(roof));
this.extrusionRoofsListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
}
}
}
else
{
TaskDialog.Show("Revit", "You should supply profile to create extrusion roof, click select button to select profile in Revit.");
}
}
catch (Exception ex)
{
TaskDialog.Show("Revit", ex.Message);
}
}
/// <summary>
/// Edit a roof's properties.
/// </summary>
/// <param name="item">It contains a roof element.</param>
private void EditRoofItem(object sender, RoofItem item)
{
try
{
m_roofsManager.BeginTransaction();
DialogResult result = DialogResult.None;
using (RoofEditorForm editorForm = new RoofEditorForm(m_roofsManager, item.Roof))
{
result = editorForm.ShowDialog();
}
if (result == DialogResult.OK)
{
if (m_roofsManager.EndTransaction() == TransactionStatus.Committed)
{
ListView listView = sender as ListView;
if (item.Update())
{
listView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
}
else
{
m_roofsManager.FootPrintRoofs.Erase(item.Roof);
listView.Items.Remove(item);
listView.Refresh();
}
}
else
{
m_roofsManager.AbortTransaction();
}
}
else
{
m_roofsManager.AbortTransaction();
}
}
catch (Exception ex)
{
TaskDialog.Show("Revit", ex.Message);
m_roofsManager.AbortTransaction();
}
}
/// <summary>
/// When the event occurred, then create a new RoofEditorForm to edit the roof.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void roofsListView_MouseDoubleClick(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
RoofItem item = null;
if (this.roofsTabControl.SelectedTab == this.footprintRoofTabPage)
{
item = this.footPrintRoofsListView.GetItemAt(e.X, e.Y) as RoofItem;
}
else
{
item = this.extrusionRoofsListView.GetItemAt(e.X, e.Y) as RoofItem;
}
if (item != null)
{
EditRoofItem(sender, item);
}
}
}
/// <summary>
/// Validate the extrusion start value.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void extrusionStartTextBox_Validating(object sender, CancelEventArgs e)
{
try
{
m_start = double.Parse(extrusionStartTextBox.Text);
}
catch
{
TaskDialog.Show("Revit", "You should input a decimal value.");
e.Cancel = true;
}
}
/// <summary>
/// Validate the extrusion end value.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void extrusionEndTextBox_Validating(object sender, CancelEventArgs e)
{
try
{
m_end = double.Parse(extrusionEndTextBox.Text);
}
catch
{
TaskDialog.Show("Revit", "You should input a decimal value.");
e.Cancel = true;
}
}
}
}
@@ -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,104 @@
//
// (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 System.Windows.Forms;
using Autodesk.Revit.DB;
namespace Revit.SDK.Samples.NewRoof.RoofForms.CS
{
/// <summary>
/// The RoofItem is used to display a roof info in the ListView as a ListViewItem.
/// </summary>
class RoofItem : ListViewItem
{
// To store the roof which the RoofItem stands for.
Autodesk.Revit.DB.RoofBase m_roof;
/// <summary>
/// The construct of the RoofItem class.
/// </summary>
/// <param name="roof"></param>
public RoofItem(Autodesk.Revit.DB.RoofBase roof) : base(roof.Id.IntegerValue.ToString())
{
m_roof = roof;
this.SubItems.Add(roof.Name);
if (m_roof is Autodesk.Revit.DB.FootPrintRoof)
{
Parameter para = roof.get_Parameter(Autodesk.Revit.DB.BuiltInParameter.ROOF_BASE_LEVEL_PARAM);
this.SubItems.Add(LevelConverter.GetLevelByID(para.AsElementId().IntegerValue).Name);
}
else if (m_roof is Autodesk.Revit.DB.ExtrusionRoof)
{
Parameter para = roof.get_Parameter(Autodesk.Revit.DB.BuiltInParameter.ROOF_CONSTRAINT_LEVEL_PARAM);
this.SubItems.Add(LevelConverter.GetLevelByID(para.AsElementId().IntegerValue).Name);
}
this.SubItems.Add(roof.RoofType.Name);
}
/// <summary>
/// When the roof was edited, then the data of the RoofItem should be updated synchronously.
/// </summary>
/// <returns>Update successfully return true, otherwise return false.</returns>
public bool Update()
{
try
{
this.SubItems[1].Text = m_roof.Name;
if (m_roof is Autodesk.Revit.DB.FootPrintRoof)
{
Parameter para = m_roof.get_Parameter(Autodesk.Revit.DB.BuiltInParameter.ROOF_BASE_LEVEL_PARAM);
this.SubItems[2].Text = LevelConverter.GetLevelByID(para.AsElementId().IntegerValue).Name;
}
else if (m_roof is Autodesk.Revit.DB.ExtrusionRoof)
{
Parameter para = m_roof.get_Parameter(Autodesk.Revit.DB.BuiltInParameter.ROOF_CONSTRAINT_LEVEL_PARAM);
this.SubItems[2].Text = LevelConverter.GetLevelByID(para.AsElementId().IntegerValue).Name;
}
this.SubItems[3].Text = m_roof.RoofType.Name;
}
catch
{
return false;
}
return true;
}
/// <summary>
/// Get the roof which the RoofItem stands for.
/// </summary>
public Autodesk.Revit.DB.RoofBase Roof
{
get
{
return m_roof;
}
}
}
}
@@ -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.NewRoof.RoofsManager.CS
{
/// <summary>
/// The ExtrusionRoofManager class is to manage the creation of the Extrusion roof.
/// </summary>
class ExtrusionRoofManager
{
// To store a reference to the commandData
ExternalCommandData m_commandData;
// To store a reference to the creation document
Autodesk.Revit.Creation.Document m_creationDoc;
// To store a reference to the creation application
Autodesk.Revit.Creation.Application m_creationApp;
/// <summary>
/// The construct of ExtrusionRoofManager class.
/// </summary>
/// <param name="commandData">A reference to the commandData.</param>
public ExtrusionRoofManager(ExternalCommandData commandData)
{
m_commandData = commandData;
m_creationDoc = m_commandData.Application.ActiveUIDocument.Document.Create;
m_creationApp = m_commandData.Application.Application.Create;
}
/// <summary>
/// Create a extrusion roof.
/// </summary>
/// <param name="profile">The profile combined of straight lines and arcs.</param>
/// <param name="refPlane">The reference plane for the extrusion roof.</param>
/// <param name="level">The reference level of the roof to be created.</param>
/// <param name="roofType">The type of the newly created roof.</param>
/// <param name="extrusionStart">The extrusion start point.</param>
/// <param name="extrusionEnd">The extrusion end point.</param>
/// <returns>Return a new created extrusion roof.</returns>
public ExtrusionRoof CreateExtrusionRoof(CurveArray profile, ReferencePlane refPlane, Level level, RoofType roofType,
double extrusionStart, double extrusionEnd)
{
ExtrusionRoof extrusionRoof = null;
Transaction createRoofTransaction = new Transaction(m_commandData.Application.ActiveUIDocument.Document, "ExtrusionRoof");
createRoofTransaction.Start();
try
{
extrusionRoof = m_creationDoc.NewExtrusionRoof(profile, refPlane, level, roofType, extrusionStart, extrusionEnd);
createRoofTransaction.Commit();
}
catch (System.Exception e)
{
createRoofTransaction.RollBack();
throw e;
}
return extrusionRoof;
}
}
}
@@ -0,0 +1,84 @@
//
// (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.NewRoof.RoofsManager.CS
{
/// <summary>
/// The FootPrintRoofManager class is to manage the creation of the footprint roof.
/// </summary>
class FootPrintRoofManager
{
// To store a reference to the commandData
ExternalCommandData m_commandData;
// To store a reference to the creation document
Autodesk.Revit.Creation.Document m_creationDoc;
// To store a reference to the creation application
Autodesk.Revit.Creation.Application m_creationApp;
/// <summary>
/// The construct of ExtrusionRoofManager class.
/// </summary>
/// <param name="commandData">A reference to the commandData.</param>
public FootPrintRoofManager(ExternalCommandData commandData)
{
m_commandData = commandData;
m_creationDoc = m_commandData.Application.ActiveUIDocument.Document.Create;
m_creationApp = m_commandData.Application.Application.Create;
}
/// <summary>
/// Create a footprint roof.
/// </summary>
/// <param name="footPrint">The footprint is a curve loop, or a wall loop, or loops combined of walls and curves</param>
/// <param name="level">The base level of the roof to be created.</param>
/// <param name="roofType">The type of the newly created roof.</param>
/// <returns>Return a new created footprint roof.</returns>
public FootPrintRoof CreateFootPrintRoof(CurveArray footPrint, Level level, RoofType roofType)
{
FootPrintRoof footprintRoof = null;
Transaction createRoofTransaction = new Transaction(m_commandData.Application.ActiveUIDocument.Document, "FootPrintRoof");
createRoofTransaction.Start();
try
{
ModelCurveArray footPrintToModelCurveMapping = new ModelCurveArray();
footprintRoof = m_creationDoc.NewFootPrintRoof(footPrint, level, roofType, out footPrintToModelCurveMapping);
createRoofTransaction.Commit();
}
catch (System.Exception e)
{
createRoofTransaction.RollBack();
throw e;
}
return footprintRoof;
}
}
}
@@ -0,0 +1,431 @@
//
// (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.Collections.ObjectModel;
using System.Windows.Forms;
using System.Text;
using System.Linq;
using Autodesk.Revit;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
using Revit.SDK.Samples.NewRoof.RoofForms.CS;
namespace Revit.SDK.Samples.NewRoof.RoofsManager.CS
{
/// <summary>
/// The kinds of roof than can be created.
/// </summary>
public enum CreateRoofKind
{
FootPrintRoof,
ExtrusionRoof
};
/// <summary>
/// The RoofsManager is used to manage the operations between Revit and UI.
/// </summary>
public class RoofsManager
{
// To store a reference to the commandData.
ExternalCommandData m_commandData;
// To store the levels info in the Revit.
List<Level> m_levels;
// To store the roof types info in the Revit.
List<RoofType> m_roofTypes;
// To store a reference to the FootPrintRoofManager to create footprint roof.
FootPrintRoofManager m_footPrintRoofManager;
// To store a reference to the ExtrusionRoofManager to create extrusion roof.
ExtrusionRoofManager m_extrusionRoofManager;
// To store the selected elements in the Revit
Selection m_selection;
// roofs list
ElementSet m_footPrintRoofs;
ElementSet m_extrusionRoofs;
// To store the footprint roof lines.
Autodesk.Revit.DB.CurveArray m_footPrint;
// To store the profile lines.
Autodesk.Revit.DB.CurveArray m_profile;
// Reference Plane for creating extrusion roof
List<ReferencePlane> m_referencePlanes;
// Transaction for manual mode
Transaction m_transaction;
// Current creating roof kind.
public CreateRoofKind RoofKind;
/// <summary>
/// The constructor of RoofsManager class.
/// </summary>
/// <param name="commandData">The ExternalCommandData</param>
public RoofsManager(ExternalCommandData commandData)
{
m_commandData = commandData;
m_levels = new List<Level>();
m_roofTypes = new List<RoofType>();
m_referencePlanes = new List<ReferencePlane>();
m_footPrint = new CurveArray();
m_profile = new CurveArray();
m_footPrintRoofManager = new FootPrintRoofManager(commandData);
m_extrusionRoofManager = new ExtrusionRoofManager(commandData);
m_selection = commandData.Application.ActiveUIDocument.Selection;
m_transaction = new Transaction(commandData.Application.ActiveUIDocument.Document, "Document");
RoofKind = CreateRoofKind.FootPrintRoof;
Initialize();
}
/// <summary>
/// Initialize the data member
/// </summary>
private void Initialize()
{
Document doc = m_commandData.Application.ActiveUIDocument.Document;
FilteredElementIterator iter = (new FilteredElementCollector(doc)).OfClass(typeof(Level)).GetElementIterator();
iter.Reset();
while (iter.MoveNext())
{
m_levels.Add(iter.Current as Level);
}
FilteredElementCollector filteredElementCollector = new FilteredElementCollector(doc);
filteredElementCollector.OfClass(typeof(RoofType));
m_roofTypes = filteredElementCollector.Cast<RoofType>().ToList<RoofType>();
// FootPrint Roofs
m_footPrintRoofs = new ElementSet();
iter = (new FilteredElementCollector(doc)).OfClass(typeof(FootPrintRoof)).GetElementIterator();
iter.Reset();
while (iter.MoveNext())
{
m_footPrintRoofs.Insert(iter.Current as FootPrintRoof);
}
// Extrusion Roofs
m_extrusionRoofs = new ElementSet();
iter = (new FilteredElementCollector(doc)).OfClass(typeof(ExtrusionRoof)).GetElementIterator();
iter.Reset();
while (iter.MoveNext())
{
m_extrusionRoofs.Insert(iter.Current as ExtrusionRoof);
}
// Reference Planes
iter = (new FilteredElementCollector(doc)).OfClass(typeof(ReferencePlane)).GetElementIterator();
iter.Reset();
while (iter.MoveNext())
{
ReferencePlane plane = iter.Current as ReferencePlane;
// just use the vertical plane
if (Math.Abs(plane.Normal.DotProduct(Autodesk.Revit.DB.XYZ.BasisZ)) < 1.0e-09)
{
if (plane.Name == "Reference Plane")
{
plane.Name = "Reference Plane" + "(" + plane.Id.IntegerValue.ToString() + ")";
}
m_referencePlanes.Add(plane);
}
}
}
/// <summary>
/// Get the Level elements.
/// </summary>
public ReadOnlyCollection<Level> Levels
{
get
{
return new ReadOnlyCollection<Level>(m_levels);
}
}
/// <summary>
/// Get the RoofTypes.
/// </summary>
public ReadOnlyCollection<RoofType> RoofTypes
{
get
{
return new ReadOnlyCollection<RoofType>(m_roofTypes);
}
}
/// <summary>
/// Get the RoofTypes.
/// </summary>
public ReadOnlyCollection<ReferencePlane> ReferencePlanes
{
get
{
return new ReadOnlyCollection<ReferencePlane>(m_referencePlanes);
}
}
/// <summary>
/// Get all the footprint roofs in Revit.
/// </summary>
public ElementSet FootPrintRoofs
{
get
{
return m_footPrintRoofs;
}
}
/// <summary>
/// Get all the extrusion roofs in Revit.
/// </summary>
public ElementSet ExtrusionRoofs
{
get
{
return m_extrusionRoofs;
}
}
/// <summary>
/// Get the footprint roof lines.
/// </summary>
public CurveArray FootPrint
{
get
{
return m_footPrint;
}
}
/// <summary>
/// Get the extrusion profile lines.
/// </summary>
public CurveArray Profile
{
get
{
return m_profile;
}
}
/// <summary>
/// Select elements in Revit to obtain the footprint roof lines or extrusion profile lines.
/// </summary>
/// <returns>A curve array to hold the footprint roof lines or extrusion profile lines.</returns>
public CurveArray WindowSelect()
{
if (RoofKind == CreateRoofKind.FootPrintRoof)
{
return SelectFootPrint();
}
else
{
return SelectProfile();
}
}
/// <summary>
/// Select elements in Revit to obtain the footprint roof lines.
/// </summary>
/// <returns>A curve array to hold the footprint roof lines.</returns>
public CurveArray SelectFootPrint()
{
m_footPrint.Clear();
while (true)
{
ElementSet es = new ElementSet();
foreach (ElementId elementId in m_selection.GetElementIds())
{
es.Insert(m_commandData.Application.ActiveUIDocument.Document.GetElement(elementId));
}
es.Clear();
IList<Element> selectResult;
try
{
selectResult = m_selection.PickElementsByRectangle();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
break;
}
if (selectResult.Count != 0)
{
foreach (Autodesk.Revit.DB.Element element in selectResult)
{
Wall wall = element as Wall;
if (wall != null)
{
LocationCurve wallCurve = wall.Location as LocationCurve;
m_footPrint.Append(wallCurve.Curve);
continue;
}
ModelCurve modelCurve = element as ModelCurve;
if (modelCurve != null)
{
m_footPrint.Append(modelCurve.GeometryCurve);
}
}
break;
}
else
{
TaskDialogResult result = TaskDialog.Show("Warning", "You should select a curve loop, or a wall loop, or loops combination \r\nof walls and curves to create a footprint roof.", TaskDialogCommonButtons.Ok | TaskDialogCommonButtons.Cancel);
if (result == TaskDialogResult.Cancel)
{
break;
}
}
}
return m_footPrint;
}
/// <summary>
/// Create a footprint roof.
/// </summary>
/// <param name="level">The base level of the roof to be created.</param>
/// <param name="roofType">The type of the newly created roof.</param>
/// <returns>Return a new created footprint roof.</returns>
public FootPrintRoof CreateFootPrintRoof(Level level, RoofType roofType)
{
FootPrintRoof roof = null;
roof = m_footPrintRoofManager.CreateFootPrintRoof(m_footPrint, level, roofType);
if (roof != null)
{
this.m_footPrintRoofs.Insert(roof);
}
return roof;
}
/// <summary>
/// Select elements in Revit to obtain the extrusion profile lines.
/// </summary>
/// <returns>A curve array to hold the extrusion profile lines.</returns>
public CurveArray SelectProfile()
{
m_profile.Clear();
while (true)
{
m_selection.GetElementIds().Clear();
IList<Element> selectResult;
try
{
selectResult = m_selection.PickElementsByRectangle();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
break;
}
if (selectResult.Count != 0)
{
foreach (Autodesk.Revit.DB.Element element in selectResult)
{
ModelCurve modelCurve = element as ModelCurve;
if (modelCurve != null)
{
m_profile.Append(modelCurve.GeometryCurve);
continue;
}
}
break;
}
else
{
TaskDialogResult result = TaskDialog.Show("Warning", "You should select a connected lines or arcs, \r\nnot closed in a loop to create extrusion roof.", TaskDialogCommonButtons.Ok | TaskDialogCommonButtons.Cancel);
if (result == TaskDialogResult.Cancel)
{
break;
}
}
}
return m_profile;
}
/// <summary>
/// Create a extrusion roof.
/// </summary>
/// <param name="refPlane">The reference plane for the extrusion roof.</param>
/// <param name="level">The reference level of the roof to be created.</param>
/// <param name="roofType">The type of the newly created roof.</param>
/// <param name="extrusionStart">The extrusion start point.</param>
/// <param name="extrusionEnd">The extrusion end point.</param>
/// <returns>Return a new created extrusion roof.</returns>
public ExtrusionRoof CreateExtrusionRoof(ReferencePlane refPlane,
Level level, RoofType roofType, double extrusionStart, double extrusionEnd)
{
ExtrusionRoof roof = null;
roof = m_extrusionRoofManager.CreateExtrusionRoof(m_profile, refPlane, level, roofType, extrusionStart, extrusionEnd);
if (roof != null)
{
m_extrusionRoofs.Insert(roof);
}
return roof;
}
/// <summary>
/// Begin a transaction.
/// </summary>
/// <returns></returns>
public TransactionStatus BeginTransaction()
{
if (m_transaction.GetStatus() == TransactionStatus.Started)
{
TaskDialog.Show("Revit", "Transaction started already");
}
return m_transaction.Start();
}
/// <summary>
/// Finish a transaction.
/// </summary>
/// <returns></returns>
public TransactionStatus EndTransaction()
{
return m_transaction.Commit();
}
/// <summary>
/// Abort a transaction.
/// </summary>
public TransactionStatus AbortTransaction()
{
return m_transaction.RollBack();
}
}
}