Get Schedule Data
Revit Macro that gets schedule info from the project
public void GetScheduleFields()
{
UIDocument uidoc = this.ActiveUIDocument; //dont need this
Document doc = this.ActiveUIDocument.Document;
Autodesk.Revit.DB.View pView = ActiveUIDocument.Document.ActiveView;
Selection selection = uidoc.Selection;
//store element id's
ICollection<ElementId> selectedIds = uidoc.Selection.GetElementIds();
/*
*
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using System.IO;
using Autodesk.Revit;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using System.Linq;
using Autodesk.Revit.DB.Structure;
namespace BIMOasis
{
/// <summary>
/// A class inherits IExternalCommand interface.
/// This class show how to create Generic Model Family by Revit API.
/// </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 ExtCmd : IExternalCommand
{
#region Class Memeber Variables
private Autodesk.Revit.ApplicationServices.Application m_revit;
private Autodesk.Revit.DB.Document m_Document;
#region Class Interface Implementation
public Autodesk.Revit.UI.Result Execute(ExternalCommandData commandData,
ref string message,
ElementSet elements)
{
*/
try
{
FilteredElementCollector ScheduleCollector = new FilteredElementCollector(doc );
ScheduleCollector.OfClass(typeof(ViewSchedule));
List<ViewSchedule> schedules = ScheduleCollector.Cast<ViewSchedule>().ToList();
if (schedules.Count > 0)
{
StringBuilder sb = new StringBuilder();
Settings documentSettings = doc.Settings;
// Get all categories of current document
Categories groups = documentSettings.Categories;
foreach (ViewSchedule sh in schedules)
{
Category c = groups.Cast<Category>().Where(cat => cat.Id == sh.Definition.CategoryId).FirstOrDefault();
if (c != null)
{
sb.AppendLine(string.Format("Sheet {0} is of Category {1}", sh.Name, c.Name));
}
TableData tbdata = sh.GetTableData();
tbdata.GetSectionData
sh.Definition ()
sh.EmbeddedDefinition.
}
TaskDialog.Show("Revit", sb.ToString());
}
}//end try
catch
{
}// end catch