Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

how to get schedule data

4 REPLIES 4
Reply
Message 1 of 5
nbrooksFL6XX
6269 Views, 4 Replies

how to get schedule data

I am *very new* to Revit & the API.

 

I need to get the data out of a schedule on a sheet.  And then using the Name of the family instance that is listed in each row , I want to search for the other parameter data for that family instance.  Basically, I need all the data in each row of the schedule, but there are other parameters for those family instances that aren't in the schedule and I need to get those data values as well. 

 

How do I do this?    I'm a bit fuzzy on whether I should be looking at the scheduleDefinition or the ViewSchedule classes.

Can anyone help?  THANK YOU, in advance!

 

4 REPLIES 4
Message 2 of 5
jeremytammik
in reply to: nbrooksFL6XX

Welcome to the Revit API!

 

In case you are not aware of it, we have a nice collection of getting started material to help you get a flying start:

 

http://thebuildingcoder.typepad.com/blog/about-the-author.html#2

 

Once you have digested that, here is a description by The Building Coder on how to easily access all schedule data:

 

http://thebuildingcoder.typepad.com/blog/2012/05/the-schedule-api-and-access-to-schedule-data.html

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 3 of 5
Anonymous
in reply to: nbrooksFL6XX

Yes, you can easily access Schedule data. Firstly, get all the schedules and read the data cell by cell. Secondly, create dictionary and store data in form of key, value pairs. Now you can use the schedule data as you want. I have tried this in Revit 2019. I hope this will work for you.

 

public void getScheduleData(Document doc)
{
    FilteredElementCollector collector = new FilteredElementCollector(doc);
    IList<Element> collection = collector.OfClass(typeof(ViewSchedule)).ToElements();

    String prompt = "ScheduleData :";
    prompt += Environment.NewLine;
foreach (Element e in collection) { ViewSchedule viewSchedule = e as ViewSchedule; TableData table = viewSchedule.GetTableData(); TableSectionData section = table.GetSectionData(SectionType.Body); int nRows = section.NumberOfRows; int nColumns = section.NumberOfColumns; if (nRows > 1) { //valueData.Add(viewSchedule.Name); List<List<string>> scheduleData = new List<List<string>>(); for (int i = 0; i < nRows; i++) { List<string> rowData = new List<string>(); for (int j = 0; j < nColumns; j++) { rowData.Add(viewSchedule.GetCellText(SectionType.Body, i, j)); } scheduleData.Add(rowData); } List<string> columnData = scheduleData[0]; scheduleData.RemoveAt(0); DataMapping(columnData, scheduleData); } } } public static void DataMapping(List<string> keyData, List<List<string>>valueData) { List<Dictionary<string, string>> items= new List<Dictionary<string, string>>(); string prompt = "Key/Value"; prompt += Environment.NewLine; foreach (List<string> list in valueData) { for (int key=0, value =0 ; key< keyData.Count && value< list.Count; key++,value++) { Dictionary<string, string> newItem = new Dictionary<string, string>(); string k = keyData[key]; string v = list[value]; newItem.Add(k, v); items.Add(newItem); } } foreach (Dictionary<string, string> item in items) { foreach (KeyValuePair<string, string> kvp in item) { if ((kvp.Key == "Count") && (kvp.Value == "")) items.Remove(item); prompt += "Key: " + kvp.Key + ",Value: " + kvp.Value; prompt += Environment.NewLine; } } Autodesk.Revit.UI.TaskDialog.Show("Revit", prompt); }

  

Message 4 of 5
Houba3314
in reply to: Anonymous

Can You please Help me I dont really understand your code im new to revit ,Do you have any tutorial or something i know the basics and i need to know how to get all the data from the schedule 

Message 5 of 5
jeremy_tammik
in reply to: Houba3314

Welcome to the Revit API!

 

Here are some pointers to getting started material:

 

https://thebuildingcoder.typepad.com/blog/about-the-author.html#2

 

Here is a sample that accesses schedule data and displays it in a Windows form, one of my favourites:

  

https://thebuildingcoder.typepad.com/blog/2012/05/the-schedule-api-and-access-to-schedule-data.html

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


Autodesk Design & Make Report