mirror of
https://github.com/jeremytammik/RevitSdkSamples.git
synced 2026-08-30 08:32:50 +00:00
added Revit 2022 SDK minus except *rvt and *rfa
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RevitAddIns>
|
||||
<AddIn Type="Command">
|
||||
<Assembly>AddSpaceAndZone.dll</Assembly>
|
||||
<ClientId>2012a65d-63d0-4e5c-8054-c81de267501d</ClientId>
|
||||
<FullClassName>Revit.SDK.Samples.AddSpaceAndZone.CS.Command</FullClassName>
|
||||
<Text>Create zone and space</Text>
|
||||
<Description>Create space/zone elements and edit zone in Revit MEP.</Description>
|
||||
<VisibilityMode>AlwaysVisible</VisibilityMode>
|
||||
<VendorId>ADSK</VendorId>
|
||||
<VendorDescription>Autodesk, www.autodesk.com</VendorDescription>
|
||||
</AddIn>
|
||||
</RevitAddIns>
|
||||
@@ -0,0 +1,113 @@
|
||||
<?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>{8CA72C14-FB27-42F8-8F6E-18BBCEA10ECB}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>AddSpaceAndZone</RootNamespace>
|
||||
<AssemblyName>AddSpaceAndZone</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="DataManager.cs" />
|
||||
<Compile Include="MainForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="MainForm.Designer.cs">
|
||||
<DependentUpon>MainForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="SpaceItem.cs" />
|
||||
<Compile Include="SpaceManager.cs" />
|
||||
<Compile Include="SpaceNode.cs" />
|
||||
<Compile Include="ZoneEditorForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="ZoneEditorForm.Designer.cs">
|
||||
<DependentUpon>ZoneEditorForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ZoneNode.cs" />
|
||||
<Compile Include="ZoneManager.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="MainForm.resx">
|
||||
<SubType>Designer</SubType>
|
||||
<DependentUpon>MainForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="ZoneEditorForm.resx">
|
||||
<SubType>Designer</SubType>
|
||||
<DependentUpon>ZoneEditorForm.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,96 @@
|
||||
//
|
||||
// (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.AddSpaceAndZone.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Implements the Revit add-in interface IExternalCommand
|
||||
/// </summary>
|
||||
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
|
||||
[Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)]
|
||||
[Autodesk.Revit.Attributes.Journaling(Autodesk.Revit.Attributes.JournalingMode.NoCommandData)]
|
||||
public class Command : IExternalCommand
|
||||
{
|
||||
/// <summary>
|
||||
/// Implement this method as an external command for Revit.
|
||||
/// </summary>
|
||||
/// <param name="commandData">An object that is passed to the external application
|
||||
/// which contains data related to the command,
|
||||
/// such as the application object and active view.</param>
|
||||
/// <param name="message">A message that can be set by the external application
|
||||
/// which will be displayed if a failure or cancellation is returned by
|
||||
/// the external command.</param>
|
||||
/// <param name="elements">A set of elements to which the external application
|
||||
/// can add elements that are to be highlighted in case of failure or cancellation.</param>
|
||||
/// <returns>Return the status of the external command.
|
||||
/// A result of Succeeded means that the API external method functioned as expected.
|
||||
/// Cancelled can be used to signify that the user cancelled the external operation
|
||||
/// at some point. Failure should be returned if the application is unable to proceed with
|
||||
/// the operation.</returns>
|
||||
public Autodesk.Revit.UI.Result Execute(Autodesk.Revit.UI.ExternalCommandData commandData,
|
||||
ref string message,
|
||||
ElementSet elements)
|
||||
{
|
||||
try
|
||||
{
|
||||
Transaction documentTransaction = new Transaction(commandData.Application.ActiveUIDocument.Document, "Document");
|
||||
documentTransaction.Start();
|
||||
|
||||
// Create a new instance of class DataManager
|
||||
DataManager dataManager = new DataManager(commandData);
|
||||
|
||||
System.Windows.Forms.DialogResult result;
|
||||
|
||||
// Create a form
|
||||
using (MainForm mainForm = new MainForm(dataManager))
|
||||
{
|
||||
result = mainForm.ShowDialog();
|
||||
}
|
||||
|
||||
if (result == System.Windows.Forms.DialogResult.OK)
|
||||
{
|
||||
documentTransaction.Commit();
|
||||
return Autodesk.Revit.UI.Result.Succeeded;
|
||||
}
|
||||
else
|
||||
{
|
||||
documentTransaction.RollBack();
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
//
|
||||
// (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.Text;
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI;
|
||||
using Autodesk.Revit.DB.Mechanical;
|
||||
|
||||
namespace Revit.SDK.Samples.AddSpaceAndZone.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// The DataManager Class is used to obtain, create or edit the Space elements and Zone elements.
|
||||
/// </summary>
|
||||
public class DataManager
|
||||
{
|
||||
ExternalCommandData m_commandData;
|
||||
List<Level> m_levels;
|
||||
SpaceManager m_spaceManager;
|
||||
ZoneManager m_zoneManager;
|
||||
Level m_currentLevel;
|
||||
Phase m_defaultPhase;
|
||||
|
||||
/// <summary>
|
||||
/// The constructor of DataManager class.
|
||||
/// </summary>
|
||||
/// <param name="commandData">The ExternalCommandData</param>
|
||||
public DataManager(ExternalCommandData commandData)
|
||||
{
|
||||
m_commandData = commandData;
|
||||
m_levels = new List<Level>();
|
||||
Initialize();
|
||||
m_currentLevel = m_levels[0];
|
||||
Parameter para = commandData.Application.ActiveUIDocument.Document.ActiveView.get_Parameter(Autodesk.Revit.DB.BuiltInParameter.VIEW_PHASE);
|
||||
Autodesk.Revit.DB.ElementId phaseId = para.AsElementId();
|
||||
m_defaultPhase = commandData.Application.ActiveUIDocument.Document.GetElement(phaseId) as Phase;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize the data member, obtain the Space and Zone elements.
|
||||
/// </summary>
|
||||
private void Initialize()
|
||||
{
|
||||
Dictionary<int, List<Space>> spaceDictionary = new Dictionary<int, List<Space>>();
|
||||
Dictionary<int, List<Zone>> zoneDictionary = new Dictionary<int, List<Zone>>();
|
||||
|
||||
Document activeDoc = m_commandData.Application.ActiveUIDocument.Document;
|
||||
|
||||
FilteredElementIterator levelsIterator = (new FilteredElementCollector(activeDoc)).OfClass(typeof(Level)).GetElementIterator();
|
||||
FilteredElementIterator spacesIterator =(new FilteredElementCollector(activeDoc)).WherePasses(new SpaceFilter()).GetElementIterator();
|
||||
FilteredElementIterator zonesIterator = (new FilteredElementCollector(activeDoc)).OfClass(typeof(Zone)).GetElementIterator();
|
||||
|
||||
levelsIterator.Reset();
|
||||
while (levelsIterator.MoveNext())
|
||||
{
|
||||
Level level = levelsIterator.Current as Level;
|
||||
if (level != null)
|
||||
{
|
||||
m_levels.Add(level);
|
||||
spaceDictionary.Add(level.Id.IntegerValue, new List<Space>());
|
||||
zoneDictionary.Add(level.Id.IntegerValue, new List<Zone>());
|
||||
}
|
||||
}
|
||||
|
||||
spacesIterator.Reset();
|
||||
while (spacesIterator.MoveNext())
|
||||
{
|
||||
Space space = spacesIterator.Current as Space;
|
||||
if (space != null)
|
||||
{
|
||||
spaceDictionary[space.LevelId.IntegerValue].Add(space);
|
||||
}
|
||||
}
|
||||
|
||||
zonesIterator.Reset();
|
||||
while (zonesIterator.MoveNext())
|
||||
{
|
||||
Zone zone = zonesIterator.Current as Zone;
|
||||
if (zone != null && activeDoc.GetElement(zone.LevelId) != null)
|
||||
{
|
||||
zoneDictionary[zone.LevelId.IntegerValue].Add(zone);
|
||||
}
|
||||
}
|
||||
|
||||
m_spaceManager = new SpaceManager(m_commandData, spaceDictionary);
|
||||
m_zoneManager = new ZoneManager(m_commandData, zoneDictionary);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the Level elements.
|
||||
/// </summary>
|
||||
public ReadOnlyCollection<Level> Levels
|
||||
{
|
||||
get
|
||||
{
|
||||
return new ReadOnlyCollection<Level>(m_levels);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a Zone element.
|
||||
/// </summary>
|
||||
public void CreateZone()
|
||||
{
|
||||
if (m_defaultPhase == null)
|
||||
{
|
||||
Autodesk.Revit.UI.TaskDialog.Show("Revit", "The phase of the active view is null, you can't create zone in a null phase");
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
this.m_zoneManager.CreateZone(m_currentLevel, m_defaultPhase);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Autodesk.Revit.UI.TaskDialog.Show("Revit", ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create some spaces.
|
||||
/// </summary>
|
||||
public void CreateSpaces()
|
||||
{
|
||||
if (m_defaultPhase == null)
|
||||
{
|
||||
Autodesk.Revit.UI.TaskDialog.Show("Revit", "The phase of the active view is null, you can't create spaces in a null phase");
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (m_commandData.Application.ActiveUIDocument.Document.ActiveView.ViewType == Autodesk.Revit.DB.ViewType.FloorPlan)
|
||||
{
|
||||
m_spaceManager.CreateSpaces(m_currentLevel, m_defaultPhase);
|
||||
}
|
||||
else
|
||||
{
|
||||
Autodesk.Revit.UI.TaskDialog.Show("Revit", "You can not create spaces in this plan view");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Autodesk.Revit.UI.TaskDialog.Show("Revit", ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the Space elements.
|
||||
/// </summary>
|
||||
/// <returns>A space list in current level.</returns>
|
||||
public List<Space> GetSpaces()
|
||||
{
|
||||
return m_spaceManager.GetSpaces(m_currentLevel);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the Zone elements.
|
||||
/// </summary>
|
||||
/// <returns>A Zone list in current level.</returns>
|
||||
public List<Zone> GetZones()
|
||||
{
|
||||
return m_zoneManager.GetZones(m_currentLevel);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update the current level.
|
||||
/// </summary>
|
||||
/// <param name="level"></param>
|
||||
public void Update(Level level)
|
||||
{
|
||||
this.m_currentLevel = level;
|
||||
}
|
||||
}
|
||||
}
|
||||
+249
@@ -0,0 +1,249 @@
|
||||
//
|
||||
// (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.AddSpaceAndZone.CS
|
||||
{
|
||||
partial class MainForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
private DataManager m_dataManager;
|
||||
|
||||
/// <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.okButton = new System.Windows.Forms.Button();
|
||||
this.cancelButton = new System.Windows.Forms.Button();
|
||||
this.levelComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.createSpacesButton = new System.Windows.Forms.Button();
|
||||
this.spacesListView = new System.Windows.Forms.ListView();
|
||||
this.spaceColumnHeader = new System.Windows.Forms.ColumnHeader();
|
||||
this.zoneColumnHeader = new System.Windows.Forms.ColumnHeader();
|
||||
this.tabControl = new System.Windows.Forms.TabControl();
|
||||
this.spaceTabPage = new System.Windows.Forms.TabPage();
|
||||
this.zoneTabPage = new System.Windows.Forms.TabPage();
|
||||
this.createZoneButton = new System.Windows.Forms.Button();
|
||||
this.editZoneButton = new System.Windows.Forms.Button();
|
||||
this.zonesTreeView = new System.Windows.Forms.TreeView();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.tabControl.SuspendLayout();
|
||||
this.spaceTabPage.SuspendLayout();
|
||||
this.zoneTabPage.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// okButton
|
||||
//
|
||||
this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
this.okButton.Location = new System.Drawing.Point(172, 433);
|
||||
this.okButton.Name = "okButton";
|
||||
this.okButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.okButton.TabIndex = 0;
|
||||
this.okButton.Text = "&Ok";
|
||||
this.okButton.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// cancelButton
|
||||
//
|
||||
this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.cancelButton.Location = new System.Drawing.Point(287, 433);
|
||||
this.cancelButton.Name = "cancelButton";
|
||||
this.cancelButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.cancelButton.TabIndex = 1;
|
||||
this.cancelButton.Text = "&Cancel";
|
||||
this.cancelButton.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// levelComboBox
|
||||
//
|
||||
this.levelComboBox.FormattingEnabled = true;
|
||||
this.levelComboBox.Location = new System.Drawing.Point(82, 29);
|
||||
this.levelComboBox.Name = "levelComboBox";
|
||||
this.levelComboBox.Size = new System.Drawing.Size(286, 21);
|
||||
this.levelComboBox.TabIndex = 2;
|
||||
this.levelComboBox.SelectedIndexChanged += new System.EventHandler(this.levelComboBox_SelectedIndexChanged);
|
||||
//
|
||||
// createSpacesButton
|
||||
//
|
||||
this.createSpacesButton.Location = new System.Drawing.Point(34, 316);
|
||||
this.createSpacesButton.Name = "createSpacesButton";
|
||||
this.createSpacesButton.Size = new System.Drawing.Size(281, 23);
|
||||
this.createSpacesButton.TabIndex = 3;
|
||||
this.createSpacesButton.Text = "Create Spaces";
|
||||
this.createSpacesButton.UseVisualStyleBackColor = true;
|
||||
this.createSpacesButton.Click += new System.EventHandler(this.createSpacesButton_Click);
|
||||
//
|
||||
// spacesListView
|
||||
//
|
||||
this.spacesListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
|
||||
this.spaceColumnHeader,
|
||||
this.zoneColumnHeader});
|
||||
this.spacesListView.Location = new System.Drawing.Point(3, 6);
|
||||
this.spacesListView.Name = "spacesListView";
|
||||
this.spacesListView.Size = new System.Drawing.Size(343, 304);
|
||||
this.spacesListView.TabIndex = 4;
|
||||
this.spacesListView.UseCompatibleStateImageBehavior = false;
|
||||
this.spacesListView.View = System.Windows.Forms.View.Details;
|
||||
//
|
||||
// spaceColumnHeader
|
||||
//
|
||||
this.spaceColumnHeader.Text = "Space";
|
||||
//
|
||||
// zoneColumnHeader
|
||||
//
|
||||
this.zoneColumnHeader.Text = "Zone";
|
||||
//
|
||||
// tabControl
|
||||
//
|
||||
this.tabControl.Controls.Add(this.spaceTabPage);
|
||||
this.tabControl.Controls.Add(this.zoneTabPage);
|
||||
this.tabControl.Location = new System.Drawing.Point(12, 54);
|
||||
this.tabControl.Name = "tabControl";
|
||||
this.tabControl.SelectedIndex = 0;
|
||||
this.tabControl.Size = new System.Drawing.Size(360, 373);
|
||||
this.tabControl.TabIndex = 5;
|
||||
//
|
||||
// spaceTabPage
|
||||
//
|
||||
this.spaceTabPage.Controls.Add(this.spacesListView);
|
||||
this.spaceTabPage.Controls.Add(this.createSpacesButton);
|
||||
this.spaceTabPage.Location = new System.Drawing.Point(4, 23);
|
||||
this.spaceTabPage.Name = "spaceTabPage";
|
||||
this.spaceTabPage.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.spaceTabPage.Size = new System.Drawing.Size(352, 346);
|
||||
this.spaceTabPage.TabIndex = 0;
|
||||
this.spaceTabPage.Text = "Spaces";
|
||||
this.spaceTabPage.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// zoneTabPage
|
||||
//
|
||||
this.zoneTabPage.Controls.Add(this.createZoneButton);
|
||||
this.zoneTabPage.Controls.Add(this.editZoneButton);
|
||||
this.zoneTabPage.Controls.Add(this.zonesTreeView);
|
||||
this.zoneTabPage.Location = new System.Drawing.Point(4, 23);
|
||||
this.zoneTabPage.Name = "zoneTabPage";
|
||||
this.zoneTabPage.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.zoneTabPage.Size = new System.Drawing.Size(352, 346);
|
||||
this.zoneTabPage.TabIndex = 1;
|
||||
this.zoneTabPage.Text = "Zones";
|
||||
this.zoneTabPage.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// createZoneButton
|
||||
//
|
||||
this.createZoneButton.Location = new System.Drawing.Point(40, 317);
|
||||
this.createZoneButton.Name = "createZoneButton";
|
||||
this.createZoneButton.Size = new System.Drawing.Size(115, 23);
|
||||
this.createZoneButton.TabIndex = 2;
|
||||
this.createZoneButton.Text = "Create Zone";
|
||||
this.createZoneButton.UseVisualStyleBackColor = true;
|
||||
this.createZoneButton.Click += new System.EventHandler(this.createZoneButton_Click);
|
||||
//
|
||||
// editZoneButton
|
||||
//
|
||||
this.editZoneButton.Location = new System.Drawing.Point(195, 317);
|
||||
this.editZoneButton.Name = "editZoneButton";
|
||||
this.editZoneButton.Size = new System.Drawing.Size(141, 23);
|
||||
this.editZoneButton.TabIndex = 1;
|
||||
this.editZoneButton.Text = "Edit Zone";
|
||||
this.editZoneButton.UseVisualStyleBackColor = true;
|
||||
this.editZoneButton.Click += new System.EventHandler(this.editZoneButton_Click);
|
||||
//
|
||||
// zonesTreeView
|
||||
//
|
||||
this.zonesTreeView.Location = new System.Drawing.Point(3, 6);
|
||||
this.zonesTreeView.Name = "zonesTreeView";
|
||||
this.zonesTreeView.ShowNodeToolTips = true;
|
||||
this.zonesTreeView.Size = new System.Drawing.Size(343, 296);
|
||||
this.zonesTreeView.TabIndex = 0;
|
||||
this.zonesTreeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.zonesTreeView_AfterSelect);
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.Location = new System.Drawing.Point(-2, 27);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(63, 23);
|
||||
this.label1.TabIndex = 6;
|
||||
this.label1.Text = "Level :";
|
||||
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
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(382, 462);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.tabControl);
|
||||
this.Controls.Add(this.levelComboBox);
|
||||
this.Controls.Add(this.cancelButton);
|
||||
this.Controls.Add(this.okButton);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "MainForm";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "AddSpaceAndZone";
|
||||
this.Load += new System.EventHandler(this.MainForm_Load);
|
||||
this.tabControl.ResumeLayout(false);
|
||||
this.spaceTabPage.ResumeLayout(false);
|
||||
this.zoneTabPage.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button okButton;
|
||||
private System.Windows.Forms.Button cancelButton;
|
||||
private System.Windows.Forms.ComboBox levelComboBox;
|
||||
private System.Windows.Forms.Button createSpacesButton;
|
||||
private System.Windows.Forms.ListView spacesListView;
|
||||
private System.Windows.Forms.TabControl tabControl;
|
||||
private System.Windows.Forms.TabPage spaceTabPage;
|
||||
private System.Windows.Forms.TabPage zoneTabPage;
|
||||
private System.Windows.Forms.TreeView zonesTreeView;
|
||||
private System.Windows.Forms.Button editZoneButton;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.Button createZoneButton;
|
||||
private System.Windows.Forms.ColumnHeader spaceColumnHeader;
|
||||
private System.Windows.Forms.ColumnHeader zoneColumnHeader;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
//
|
||||
// (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.DB.Mechanical;
|
||||
|
||||
namespace Revit.SDK.Samples.AddSpaceAndZone.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// The MainForm Class is the main user interface to manage the Space elements and Zone elements
|
||||
/// </summary>
|
||||
public partial class MainForm : System.Windows.Forms.Form
|
||||
{
|
||||
/// <summary>
|
||||
/// The default constructor of MainForm.
|
||||
/// </summary>
|
||||
private MainForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The constructor of MainForm.
|
||||
/// </summary>
|
||||
public MainForm(DataManager dataManager)
|
||||
{
|
||||
m_dataManager = dataManager;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When the levelComboBox selected index is changed, update the spacesListView and zonesTreeView.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void levelComboBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
Update(levelComboBox.SelectedItem as Level);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When the MainForm is loaded, initialize related controls.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void MainForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
// levelComboBox
|
||||
this.levelComboBox.DataSource = m_dataManager.Levels;
|
||||
this.levelComboBox.DisplayMember = "Name";
|
||||
this.levelComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
|
||||
// EditZoneButton
|
||||
this.editZoneButton.Enabled = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When createSpacesButton is clicked, then create spaces and update the spacesListView
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void createSpacesButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
m_dataManager.CreateSpaces();
|
||||
Update(levelComboBox.SelectedItem as Level);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When editZoneButton is clicked, show the ZoneEditorForm to edit the selected ZoneNode.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void editZoneButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
ZoneNode zoneNode = this.zonesTreeView.SelectedNode as ZoneNode;
|
||||
if (zoneNode != null)
|
||||
{
|
||||
using (ZoneEditorForm zoneEditorForm = new ZoneEditorForm(m_dataManager, zoneNode))
|
||||
{
|
||||
zoneEditorForm.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
Update(this.levelComboBox.SelectedItem as Level);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update the spacesListView and spacesListView.
|
||||
/// </summary>
|
||||
/// <param name="level"></param>
|
||||
private void Update(Level level)
|
||||
{
|
||||
this.spacesListView.Items.Clear();
|
||||
this.zonesTreeView.Nodes.Clear();
|
||||
|
||||
// DataManager
|
||||
m_dataManager.Update(level);
|
||||
|
||||
// spacesListView
|
||||
List<Space> spaces = m_dataManager.GetSpaces();
|
||||
foreach (Space space in spaces)
|
||||
{
|
||||
this.spacesListView.Items.Add(new SpaceItem(space));
|
||||
}
|
||||
|
||||
// zonesTreeView
|
||||
List<Zone> zones = m_dataManager.GetZones();
|
||||
foreach (Zone zone in zones)
|
||||
{
|
||||
int nodeIndex = this.zonesTreeView.Nodes.Add(new ZoneNode(zone));
|
||||
foreach (Space spaceInZone in zone.Spaces)
|
||||
{
|
||||
this.zonesTreeView.Nodes[nodeIndex].Nodes.Add(new SpaceNode(spaceInZone));
|
||||
}
|
||||
}
|
||||
this.zonesTreeView.ExpandAll();
|
||||
|
||||
this.zonesTreeView.Update();
|
||||
this.spacesListView.Update();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When createZoneButton is clicked, then create a new Zone element.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void createZoneButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.m_dataManager.CreateZone();
|
||||
Update(levelComboBox.SelectedItem as Level);
|
||||
}
|
||||
|
||||
private void zonesTreeView_AfterSelect(object sender, TreeViewEventArgs e)
|
||||
{
|
||||
if (e.Node is ZoneNode)
|
||||
{
|
||||
this.editZoneButton.Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.editZoneButton.Enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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,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("AddSpaceAndZone")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("AddSpaceAndZone")]
|
||||
[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("48a248bd-204e-4472-9c8e-d6346211ff83")]
|
||||
|
||||
// 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")]
|
||||
Binary file not shown.
@@ -0,0 +1,65 @@
|
||||
//
|
||||
// (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;
|
||||
using Autodesk.Revit.DB.Mechanical;
|
||||
|
||||
namespace Revit.SDK.Samples.AddSpaceAndZone.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// The SpaceItem class inherit ListViewItem Class, it is used
|
||||
/// to display the Spaces is a ListView, each SpaceItem contains
|
||||
/// a Space element.
|
||||
/// </summary>
|
||||
class SpaceItem : ListViewItem
|
||||
{
|
||||
Space m_space;
|
||||
public SpaceItem(Space space) : base(space.Name)
|
||||
{
|
||||
m_space = space;
|
||||
base.Text = space.Name;
|
||||
if (space.Zone != null)
|
||||
{
|
||||
base.SubItems.Add(space.Zone.Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
base.SubItems.Add("Default");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the Space element in the SpaceItem.
|
||||
/// </summary>
|
||||
public Space Space
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_space;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
//
|
||||
// (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;
|
||||
|
||||
using Autodesk.Revit.DB.Mechanical;
|
||||
|
||||
namespace Revit.SDK.Samples.AddSpaceAndZone.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// The SpaceManager class is used to manage the Spaces elements in the current document.
|
||||
/// </summary>
|
||||
class SpaceManager
|
||||
{
|
||||
ExternalCommandData m_commandData;
|
||||
Dictionary<int, List<Space>> m_spaceDictionary;
|
||||
|
||||
/// <summary>
|
||||
/// The constructor of SpaceManager class.
|
||||
/// </summary>
|
||||
/// <param name="data">The ExternalCommandData</param>
|
||||
/// <param name="spaceData">The spaceData contains all the Space elements in different level.</param>
|
||||
public SpaceManager(ExternalCommandData data, Dictionary<int,List<Space>> spaceData)
|
||||
{
|
||||
m_commandData = data;
|
||||
m_spaceDictionary = spaceData;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the Spaces elements in a specified level.
|
||||
/// </summary>
|
||||
/// <param name="level"></param>
|
||||
/// <returns>Return a space list</returns>
|
||||
public List<Space> GetSpaces(Level level)
|
||||
{
|
||||
return m_spaceDictionary[level.Id.IntegerValue];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create the space for each closed wall loop or closed space separation in the active view.
|
||||
/// </summary>
|
||||
/// <param name="level">The level in which the spaces is to exist.</param>
|
||||
/// <param name="phase">The phase in which the spaces is to exist.</param>
|
||||
public void CreateSpaces(Level level, Phase phase)
|
||||
{
|
||||
try
|
||||
{
|
||||
ICollection<ElementId> elements = m_commandData.Application.ActiveUIDocument.Document.Create.NewSpaces2(level, phase, this.m_commandData.Application.ActiveUIDocument.Document.ActiveView);
|
||||
foreach (ElementId elem in elements)
|
||||
{
|
||||
Space space = m_commandData.Application.ActiveUIDocument.Document.GetElement(elem) as Space;
|
||||
if (space != null)
|
||||
{
|
||||
m_spaceDictionary[level.Id.IntegerValue].Add(space);
|
||||
}
|
||||
}
|
||||
if (elements == null || elements.Count == 0)
|
||||
{
|
||||
Autodesk.Revit.UI.TaskDialog.Show("Revit", "There is no enclosed loop in " + level.Name);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Autodesk.Revit.UI.TaskDialog.Show("Revit", ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
//
|
||||
// (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;
|
||||
|
||||
using Autodesk.Revit.DB.Mechanical;
|
||||
|
||||
namespace Revit.SDK.Samples.AddSpaceAndZone.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// The SpaceNode class inherit TreeNode Class, it is used
|
||||
/// to display the Spaces is a TreeView, each SpaceNode contains
|
||||
/// a Space element.
|
||||
/// </summary>
|
||||
class SpaceNode : TreeNode
|
||||
{
|
||||
Space m_space;
|
||||
|
||||
/// <summary>
|
||||
/// The constructor of SpaceNode class
|
||||
/// </summary>
|
||||
/// <param name="space"></param>
|
||||
public SpaceNode(Space space)
|
||||
: base(space.Name)
|
||||
{
|
||||
m_space = space;
|
||||
base.Text = space.Name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the Zone element in the ZoneNode.
|
||||
/// </summary>
|
||||
public Space Space
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_space;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
//
|
||||
// (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 Autodesk.Revit.DB.Mechanical;
|
||||
|
||||
namespace Revit.SDK.Samples.AddSpaceAndZone.CS
|
||||
{
|
||||
partial class ZoneEditorForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
private Zone m_zone;
|
||||
private ZoneNode m_zoneNode;
|
||||
private DataManager m_dataManager;
|
||||
/// <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.availableSpacesListView = new System.Windows.Forms.ListView();
|
||||
this.columnHeader1 = new System.Windows.Forms.ColumnHeader();
|
||||
this.columnHeader2 = new System.Windows.Forms.ColumnHeader();
|
||||
this.currentSpacesListView = new System.Windows.Forms.ListView();
|
||||
this.addSpaceButton = new System.Windows.Forms.Button();
|
||||
this.removeSpaceButton = new System.Windows.Forms.Button();
|
||||
this.okButton = new System.Windows.Forms.Button();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// availableSpacesListView
|
||||
//
|
||||
this.availableSpacesListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
|
||||
this.columnHeader1,
|
||||
this.columnHeader2});
|
||||
this.availableSpacesListView.Location = new System.Drawing.Point(12, 40);
|
||||
this.availableSpacesListView.Name = "availableSpacesListView";
|
||||
this.availableSpacesListView.Size = new System.Drawing.Size(135, 167);
|
||||
this.availableSpacesListView.TabIndex = 0;
|
||||
this.availableSpacesListView.UseCompatibleStateImageBehavior = false;
|
||||
this.availableSpacesListView.View = System.Windows.Forms.View.Details;
|
||||
//
|
||||
// columnHeader1
|
||||
//
|
||||
this.columnHeader1.Text = "Space";
|
||||
this.columnHeader1.Width = 63;
|
||||
//
|
||||
// columnHeader2
|
||||
//
|
||||
this.columnHeader2.Text = "Zone";
|
||||
this.columnHeader2.Width = 68;
|
||||
//
|
||||
// currentSpacesListView
|
||||
//
|
||||
this.currentSpacesListView.Location = new System.Drawing.Point(247, 40);
|
||||
this.currentSpacesListView.Name = "currentSpacesListView";
|
||||
this.currentSpacesListView.Size = new System.Drawing.Size(135, 167);
|
||||
this.currentSpacesListView.TabIndex = 1;
|
||||
this.currentSpacesListView.UseCompatibleStateImageBehavior = false;
|
||||
this.currentSpacesListView.View = System.Windows.Forms.View.List;
|
||||
//
|
||||
// addSpaceButton
|
||||
//
|
||||
this.addSpaceButton.Location = new System.Drawing.Point(166, 83);
|
||||
this.addSpaceButton.Name = "addSpaceButton";
|
||||
this.addSpaceButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.addSpaceButton.TabIndex = 2;
|
||||
this.addSpaceButton.Text = "Add";
|
||||
this.addSpaceButton.UseVisualStyleBackColor = true;
|
||||
this.addSpaceButton.Click += new System.EventHandler(this.addSpaceButton_Click);
|
||||
//
|
||||
// removeSpaceButton
|
||||
//
|
||||
this.removeSpaceButton.Location = new System.Drawing.Point(166, 129);
|
||||
this.removeSpaceButton.Name = "removeSpaceButton";
|
||||
this.removeSpaceButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.removeSpaceButton.TabIndex = 3;
|
||||
this.removeSpaceButton.Text = "&Remove";
|
||||
this.removeSpaceButton.UseVisualStyleBackColor = true;
|
||||
this.removeSpaceButton.Click += new System.EventHandler(this.removeSpaceButton_Click);
|
||||
//
|
||||
// okButton
|
||||
//
|
||||
this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
this.okButton.Location = new System.Drawing.Point(166, 224);
|
||||
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);
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(9, 13);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(92, 13);
|
||||
this.label1.TabIndex = 5;
|
||||
this.label1.Text = "Available Spaces:";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(244, 13);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(114, 13);
|
||||
this.label2.TabIndex = 6;
|
||||
this.label2.Text = "Currrent Zone Spaces:";
|
||||
//
|
||||
// ZoneEditorForm
|
||||
//
|
||||
this.AcceptButton = this.okButton;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(394, 259);
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.okButton);
|
||||
this.Controls.Add(this.removeSpaceButton);
|
||||
this.Controls.Add(this.addSpaceButton);
|
||||
this.Controls.Add(this.currentSpacesListView);
|
||||
this.Controls.Add(this.availableSpacesListView);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "ZoneEditorForm";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "ZoneEditorForm";
|
||||
this.Load += new System.EventHandler(this.ZoneEditorForm_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.ListView availableSpacesListView;
|
||||
private System.Windows.Forms.ListView currentSpacesListView;
|
||||
private System.Windows.Forms.Button addSpaceButton;
|
||||
private System.Windows.Forms.Button removeSpaceButton;
|
||||
private System.Windows.Forms.Button okButton;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.ColumnHeader columnHeader1;
|
||||
private System.Windows.Forms.ColumnHeader columnHeader2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
//
|
||||
// (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.DB.Mechanical;
|
||||
|
||||
namespace Revit.SDK.Samples.AddSpaceAndZone.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// The ZoneEditorForm Class the user interface to edit a Zone element.
|
||||
/// </summary>
|
||||
public partial class ZoneEditorForm : System.Windows.Forms.Form
|
||||
{
|
||||
/// <summary>
|
||||
/// The default constructor of ZoneEditorForm class.
|
||||
/// </summary>
|
||||
private ZoneEditorForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The constructor of ZoneEditorForm class.
|
||||
/// </summary>
|
||||
/// <param name="dataManager"></param>
|
||||
/// <param name="zoneNode"></param>
|
||||
public ZoneEditorForm(DataManager dataManager, ZoneNode zoneNode)
|
||||
{
|
||||
m_dataManager = dataManager;
|
||||
m_zoneNode = zoneNode;
|
||||
m_zone = m_zoneNode.Zone;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When the addSpace Button is clicked, the selected spaces will be added to the
|
||||
/// current Zone element.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void addSpaceButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
SpaceSet set = new SpaceSet();
|
||||
foreach (SpaceItem item in this.availableSpacesListView.SelectedItems)
|
||||
{
|
||||
set.Insert(item.Space);
|
||||
}
|
||||
|
||||
m_zone.AddSpaces(set);
|
||||
|
||||
UpdateSpaceList();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// When the removeSpace Button is clicked, the selected spaces will be removed from the
|
||||
/// current Zone element.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void removeSpaceButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
SpaceSet set = new SpaceSet();
|
||||
foreach (SpaceItem item in this.currentSpacesListView.SelectedItems)
|
||||
{
|
||||
set.Insert(item.Space);
|
||||
}
|
||||
|
||||
m_zone.RemoveSpaces(set);
|
||||
UpdateSpaceList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When the ZoneEditorForm is loaded, update the AvailableSpacesListView and CurrentSpacesListView
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ZoneEditorForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
this.Text = "Edit Zone : " + m_zone.Name;
|
||||
UpdateSpaceList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update the AvailableSpacesListView and CurrentSpacesListView
|
||||
/// </summary>
|
||||
private void UpdateSpaceList()
|
||||
{
|
||||
this.availableSpacesListView.Items.Clear();
|
||||
this.currentSpacesListView.Items.Clear();
|
||||
|
||||
// AvailableSpacesListView
|
||||
foreach (Space space in m_dataManager.GetSpaces())
|
||||
{
|
||||
if (m_zone.Spaces.Contains(space) == false)
|
||||
{
|
||||
this.availableSpacesListView.Items.Add(new SpaceItem(space));
|
||||
}
|
||||
}
|
||||
|
||||
// CurrentSpacesListView
|
||||
foreach (Space space in m_zone.Spaces)
|
||||
{
|
||||
this.currentSpacesListView.Items.Add(new SpaceItem(space));
|
||||
}
|
||||
|
||||
this.availableSpacesListView.Update();
|
||||
this.currentSpacesListView.Update();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When OK button is clicked, close the ZoneEditorForm.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void okButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@@ -0,0 +1,112 @@
|
||||
//
|
||||
// (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;
|
||||
using Autodesk.Revit.DB.Mechanical;
|
||||
|
||||
namespace Revit.SDK.Samples.AddSpaceAndZone.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// The ZoneManager class is used to manage the Zone elements in the current document.
|
||||
/// </summary>
|
||||
class ZoneManager
|
||||
{
|
||||
ExternalCommandData m_commandData;
|
||||
Dictionary<int, List<Zone>> m_zoneDictionary;
|
||||
Level m_currentLevel;
|
||||
Zone m_currentZone;
|
||||
|
||||
/// <summary>
|
||||
/// The constructor of ZoneManager class.
|
||||
/// </summary>
|
||||
/// <param name="commandData">The ExternalCommandData</param>
|
||||
/// <param name="zoneData">The spaceData contains all the Zone elements in different level.</param>
|
||||
public ZoneManager(ExternalCommandData commandData, Dictionary<int, List<Zone>> zoneData)
|
||||
{
|
||||
m_commandData = commandData;
|
||||
m_zoneDictionary = zoneData;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a zone in a specified level and phase.
|
||||
/// </summary>
|
||||
/// <param name="level"></param>
|
||||
/// <param name="phase"></param>
|
||||
public void CreateZone(Level level, Phase phase)
|
||||
{
|
||||
Zone zone = m_commandData.Application.ActiveUIDocument.Document.Create.NewZone(level, phase);
|
||||
if (zone != null)
|
||||
{
|
||||
this.m_zoneDictionary[level.Id.IntegerValue].Add(zone);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add some spaces to current Zone.
|
||||
/// </summary>
|
||||
/// <param name="spaces"></param>
|
||||
public void AddSpaces(SpaceSet spaces)
|
||||
{
|
||||
m_currentZone.AddSpaces(spaces);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove some spaces to current Zone.
|
||||
/// </summary>
|
||||
/// <param name="spaces"></param>
|
||||
public void RemoveSpaces(SpaceSet spaces)
|
||||
{
|
||||
m_currentZone.RemoveSpaces(spaces);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the Zone elements in a specified level.
|
||||
/// </summary>
|
||||
/// <param name="level"></param>
|
||||
/// <returns>Return a zone list</returns>
|
||||
public List<Zone> GetZones(Level level)
|
||||
{
|
||||
m_currentLevel = level;
|
||||
return m_zoneDictionary[level.Id.IntegerValue];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get/Set the Current Zone element.
|
||||
/// </summary>
|
||||
public Zone CurrentZone
|
||||
{
|
||||
get
|
||||
{
|
||||
return CurrentZone;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_currentZone = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
//
|
||||
// (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;
|
||||
using Autodesk.Revit.DB.Mechanical;
|
||||
|
||||
namespace Revit.SDK.Samples.AddSpaceAndZone.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// The ZoneNode class inherit TreeNode Class, it is used
|
||||
/// to display the Zones is a TreeView, each ZoneNode contains
|
||||
/// a Zone element.
|
||||
/// </summary>
|
||||
public class ZoneNode : TreeNode
|
||||
{
|
||||
Zone m_zone;
|
||||
|
||||
/// <summary>
|
||||
/// The constructor of ZoneNode class
|
||||
/// </summary>
|
||||
/// <param name="zone"></param>
|
||||
public ZoneNode(Zone zone)
|
||||
: base(zone.Name)
|
||||
{
|
||||
m_zone = zone;
|
||||
base.Text = m_zone.Name;
|
||||
base.ToolTipText = "Phase: " + m_zone.Phase.Name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the Zone element in the ZoneNode.
|
||||
/// </summary>
|
||||
public Zone Zone
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_zone;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user