//
// (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.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Autodesk.Revit;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
namespace Revit.SDK.Samples.CurtainSystem.CS.Data
{
///
/// maintains all the data used in the sample
///
public class MyDocument
{
// object which contains reference of Revit Applicatio
ExternalCommandData m_commandData;
///
/// object which contains reference of Revit Applicatio
///
public ExternalCommandData CommandData
{
get
{
return m_commandData;
}
set
{
m_commandData = value;
}
}
// the active UI document of Revit
Autodesk.Revit.UI.UIDocument m_uiDocument;
///
/// the active document of Revit
///
public Autodesk.Revit.UI.UIDocument UIDocument
{
get
{
return m_uiDocument;
}
}
Autodesk.Revit.DB.Document m_document;
public Autodesk.Revit.DB.Document Document
{
get { return m_document; }
}
// the data of the created curtain systems
CurtainSystem.SystemData m_systemData;
///
/// the data of the created curtain systems
///
public CurtainSystem.SystemData SystemData
{
get
{
return m_systemData;
}
set
{
m_systemData = value;
}
}
// all the faces of the parallelepiped mass
FaceArray m_massFaceArray;
///
/// // all the faces of the parallelepiped mass
///
public FaceArray MassFaceArray
{
get
{
return m_massFaceArray;
}
set
{
m_massFaceArray = value;
}
}
// the curtain system type of the active Revit document, used for curtain system creation
CurtainSystemType m_curtainSystemType;
///
/// the curtain system type of the active Revit document, used for curtain system creation
///
public CurtainSystemType CurtainSystemType
{
get
{
return m_curtainSystemType;
}
set
{
m_curtainSystemType = value;
}
}
// the message shown when there's a fatal error in the sample
string m_fatalErrorMsg = null;
///
/// the message shown when there's a fatal error in the sample
///
public string FatalErrorMsg
{
get
{
return m_fatalErrorMsg;
}
set
{
m_fatalErrorMsg = value;
if (false == string.IsNullOrEmpty(m_fatalErrorMsg) &&
null != FatalErrorEvent)
{
FatalErrorEvent(m_fatalErrorMsg);
}
}
}
///
/// occurs only when the message was updated
/// the delegate method to handle the message update event
///
public delegate void MessageChangedHandler();
///
/// the event triggered when message updated/changed
///
public event MessageChangedHandler MessageChanged;
///
/// occurs only when there's a fatal error
/// the delegate method to handle the fatal error event
///
///
public delegate void FatalErrorHandler(string errorMsg);
///
/// the event triggered when the sample meets a fatal error
///
public event FatalErrorHandler FatalErrorEvent;
// store the message of the sample
private KeyValuePair m_message;
///
/// store the message of the sample
///
public KeyValuePair Message
{
get
{
return m_message;
}
set
{
m_message = value;
if (null != MessageChanged)
{
MessageChanged();
}
}
}
///
/// constructor
///
///
/// object which contains reference of Revit Application
///
public MyDocument(ExternalCommandData commandData)
{
m_commandData = commandData;
m_uiDocument = m_commandData.Application.ActiveUIDocument;
m_document = m_uiDocument.Document;
// initialize the curtain system data
m_systemData = new CurtainSystem.SystemData(this);
// get the curtain system type of the active Revit document
GetCurtainSystemType();
}
///
/// get the curtain system type from the active Revit document
///
private void GetCurtainSystemType()
{
FilteredElementCollector filteredElementCollector = new FilteredElementCollector(m_document);
filteredElementCollector.OfClass(typeof(CurtainSystemType));
m_curtainSystemType = filteredElementCollector.FirstElement() as CurtainSystemType;
}
} // end of class
}