How to get schedulable field values using C#?

How to get schedulable field values using C#?

Anonymous
Not applicable
2,418 Views
4 Replies
Message 1 of 5

How to get schedulable field values using C#?

Anonymous
Not applicable

Hi,

I am new to Revit API and am working in C#. I would like to know how to get the schedulable field values using c#. I followed the below article but it seems taking long time to get the table data.

https://boostyourbim.wordpress.com/2013/03/27/getcelltext-contents-of-schedule-cells-in-2014/

 

Can you please share the alternate details of how to get the value of schedulable fields using C#? These schedulable fields are shared parameter. One field type is instance and other one is Count.

 

Thanks in advance.

0 Likes
2,419 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable

You could make it faster like this:

First just get the tablesection data separately:

TableSectionData tableSectionData = viewSchedule.GetTableData().GetSectionData(SectionType.Body);

Get the size of the table:

int Rows = tableSectionData.NumberOfRows;
int Columns = tableSectionData.NumberOfColumns;

And if you have all these, you can use the new variables like this:

 for (int i = 0; i < Rows; i++)
{
for (int j = 0; j < Columns; j++)
{
data += tableSectionData.GetCellText(i, j) + ",";
}
// remove the trailing "," after the last cell and add a newline for the end of this row
data = data.TrimEnd(',') + "\n";
}

I modified the for loop you linked, so it will be easier to use.

Make sure you use the tableSectionData in the for loop.

 

In my test schedule it reduced the time from 4900ms to 13ms.

0 Likes
Message 3 of 5

jeremytammik
Autodesk
Autodesk

I just answered the same question on StackOverflow:

 

https://stackoverflow.com/questions/51335990/how-to-get-schedule-element-data-in-revit-using-c-sharp

 

Maybe you can also use `ViewSchedule.Export` as demonstrated by The Building Coder discussing The Schedule API and Access to 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

0 Likes
Message 4 of 5

Anonymous
Not applicable

Hi Peter,

Thanks for your reply. I applied your code but it seems no luck and it is taking 10 seconds to get the data.

Is any other alternate solution?

Thanks in advance.

0 Likes
Message 5 of 5

Anonymous
Not applicable

Hi Jeremy,

It's also taking 10 to 15 seconds for exporting the data into txt file.

Could you please share any other solution? I used the below code to get the schedulable fields for the view. But I am unable to get the values of these fields. CONTROL_MARK is instance type and Count is Count type.

 

var fields = viewSchedule.Definition.GetSchedulableFields()
                                .Where(f => f.GetName(document) == "CONTROL_MARK" || f.GetName(document) == "Count")
                                .ToList();
0 Likes