Here is a quick little post, with a surprisingly short and simple answer to a short and seemingly difficult Revit API question.
Before getting to that, I will just mention that I arrived safe and sound in Paris for a developer conference here. I had a walk in the sunset on the north bank of the Seine from the Gare de Lyon along the industrial areas on Quai de Bercy and crossed the river over the new-built Pont National to reach the rue de Tolbiac by a rather roundabout route.
So, back to Revit; how can we easily retrieve all the elements listed in a schedule view?
Question: The Revit 2013 API finally enabled the creation of schedule views, which is great.
I would also need to query that schedule and retrieve all the element ids of the elements contained in it.
Currently, I am using the workaround of exporting the schedule and then comparing with elements within the project, which takes a considerable amount of time.
Is there any simpler way to achieve this?
Answer: Yes, there is.
The schedule is a view, and its view id can be passed in to the filtered element collector just like any other.
That will return the relevant elements.
Sorry you had to go to all that unnecessary trouble :-)
Many thanks to Guy Robinson for pointing this out!
Yes Guy pointed that out to me a few months ago as well.
A Fantastic tip that speed things up no end :)
Posted by: Phillip Miller | December 12, 2012 at 05:28
Dear Phillip,
Yes, thank you for asking at the time. I hope it is of similar use to others as well :-)
Cheers, Jeremy.
Posted by: Jeremy Tammik | December 12, 2012 at 05:48
Dear Jeremy,
Could u please provide some sample code to illustrate this new feature in 2013 API to extract data from schedules. (Without going through the export procedure).
Thanks
Posted by: AbdulNaafay | December 19, 2012 at 15:08
Dear AbdulNaafay,
Sure. Here it is:
http://thebuildingcoder.typepad.com/blog/2012/05/the-schedule-api-and-access-to-schedule-data.html
Cheers, Jeremy.
Posted by: Jeremy Tammik | December 19, 2012 at 16:25
Dear Jeremy,
Thank you. I would like to know if it is possible to directly iterate through the rows in a schedule to extract data without the need of exporting it to text file and reading the data from the file.
Posted by: AbdulNaafay | December 20, 2012 at 03:13
Dear AbdulNaafay,
Ok, I see. Perfectly valid request, of course. Sorry, not right now. This is an obvious wish list item to enhance the existing functionality, though, so it is sure to come soon.
Cheers, Jeremy.
Posted by: Jeremy Tammik | December 28, 2012 at 06:24
Is it possible to set the appearance of a viewschedule (IE. fonts)? I found a parameter called "appearance" but it is null.
Posted by: Paul H | December 30, 2012 at 18:57
Dear Paul,
Not right now, sorry to say. Perfectly valid request, of course. This is an obvious wish list item to enhance the existing functionality, though, which was only just added in the last release, so it is probable to come soon.
Cheers, Jeremy.
Posted by: Jeremy Tammik | January 02, 2013 at 16:30
Hi Jeremy.
Thanks a lot for the post. Thats exactly that I need!
I wanted to determined Schedules on a Sheet and could not find how to retrieve its via API.
The solution is:
FilteredElementCollector col2 =
new FilteredElementCollector(doc, viewSheet.Id);
var scheduleSheets =
col2
.OfClass(typeof(ScheduleSheetInstance))
.OfType()
.ToList();
foreach (var scheduleSheetInstance in scheduleSheets)
{
if (scheduleSheetInstance.ScheduleId != ElementId.InvalidElementId)
{
var schedule =
doc.GetElement(scheduleSheetInstance.ScheduleId) as ViewSchedule;
}
}
To get all elements belong to Schedule:
var elementsOnSchedule =
col2
.WhereElementIsNotElementType()
.ToElements()
.Where(e=>!(e is Material))
.ToList();
I don't know why, but on default all schedules include all materials in the project. I exclude it by .Where(e=>!(e is Material)). If you know, please explain.
Regards,
Victor.
P.S. Sorry. The angle brackets have disappeared:(
Posted by: Victor Chekalin | February 04, 2013 at 00:12
Dear Victor,
Thank you for the information. Do you think we should publish this as a separate post? Might it be useful to others as well? If so, please email me a solution and maybe a little sample model to test it on, and I will promote this to a main blog post on its own.
Thank you!
Cheers, Jeremy.
Posted by: Jeremy Tammik | February 08, 2013 at 08:18
Hi Jeremy,
I was wondering, in regards to Revit Schedules, can you access the element that defines rows in a schedule?
for instance, if you have sorted a schedule and suppressed the instances so that the count for each row is greater than one, can you create a collection of elements and set the collections mark value?
or do you need to some how programmatically identify the sorting being applied and run the transaction separately and ignore the schedule completely?
Thanks Much!!
Posted by: Matthew Nelson | December 07, 2013 at 18:00
Dear Matthew,
Thank you for posting this as a comment.
I am not aware of any such element that controls the schedule behaviour.
To find out whether it works the way you suggest, I would set up the required situation manually through the user interface and then explore it using RevitLookup, the BipChecker, the interactive Python or Ruby shell, and any other tools that you find useful to detect the differences.
That might tell you how to achieve your manual adjustment programmatically as well, if you are lucky and it is possible at all.
What are you actually trying to achieve? Do you have to have the results displayed in a schedule like this, or are you only after the results themselves? Do you have to modify an existing schedule, or could you simply set up a completely new schedule satisfying your needs?
As far as I am aware, the schedule creation API enables you to set up all possible kinds of schedules. I may be wrong, though.
Please let us know what you find out. Thank you.
Cheers, Jeremy.
Posted by: Jeremy Tammik | December 08, 2013 at 03:03
I was trying to have a value populate similar to a mark value. When a set of criteria was met, the value would be "A1" or "A2" etc. to shortcut the process, i wanted to use the existing schedule to accomplish the goal.
Posted by: Matthew Nelson | December 11, 2013 at 23:51
Hi Jeremy,
Unfortunately, this technique does not work if the schedule includes elements from RVT Links and it is those elements that you want to obtain.
Harry
Posted by: Harry Mattison | January 06, 2015 at 20:35
Dear Harry,
Happy New Year to you!
Oh dear, that sounds bad. Are you aware of any possible workaround?
Cheers, Jeremy.
Posted by: Jeremy Tammik | January 07, 2015 at 03:04