//
// (C) Copyright 2003-2023 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
{
///
/// The ZoneManager class is used to manage the Zone elements in the current document.
///
class ZoneManager
{
ExternalCommandData m_commandData;
Dictionary> m_zoneDictionary;
Level m_currentLevel;
Zone m_currentZone;
///
/// The constructor of ZoneManager class.
///
/// The ExternalCommandData
/// The spaceData contains all the Zone elements in different level.
public ZoneManager(ExternalCommandData commandData, Dictionary> zoneData)
{
m_commandData = commandData;
m_zoneDictionary = zoneData;
}
///
/// Create a zone in a specified level and phase.
///
///
///
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].Add(zone);
}
}
///
/// Add some spaces to current Zone.
///
///
public void AddSpaces(SpaceSet spaces)
{
m_currentZone.AddSpaces(spaces);
}
///
/// Remove some spaces to current Zone.
///
///
public void RemoveSpaces(SpaceSet spaces)
{
m_currentZone.RemoveSpaces(spaces);
}
///
/// Get the Zone elements in a specified level.
///
///
/// Return a zone list
public List GetZones(Level level)
{
m_currentLevel = level;
return m_zoneDictionary[level.Id];
}
///
/// Get/Set the Current Zone element.
///
public Zone CurrentZone
{
get
{
return CurrentZone;
}
set
{
m_currentZone = value;
}
}
}
}