Material Takeoff Schedule for Selected Elements

Material Takeoff Schedule for Selected Elements

yafimski
Contributor Contributor
2,854 Views
5 Replies
Message 1 of 6

Material Takeoff Schedule for Selected Elements

yafimski
Contributor
Contributor

Hi,

I'm trying to understand if it's possible to create a Material Takeoff ViewSchedule for specific elements selected.

 

I know that I can create a schedule for the "Category" of the ElementIds of the selected elements:

schedule = ViewSchedule.CreateMaterialTakeoff(document, selectedElementCategoryId);

but I'm not sure if that's the same as the actual elements themselves.

 

Can anyone assist to clarify this?

 

Thanks

0 Likes
Accepted solutions (1)
2,855 Views
5 Replies
Replies (5)
Message 2 of 6

RPTHOMAS108
Mentor
Mentor

Probably not directly. You could try using .AddFilter and adding a selection filter but I assume that would fail since it isn't something you can do in the UI and Schedules don't support visibility graphics.

 

An indirect method may be to add a shared parameter value to all elements of the category and set a uniform value for the elements within the selection, then filter by that in the schedule. This is a standard approach within the UI so could definitely be automated with the API. Would use a unique string such as a GUID so that every time the command is run elements with the parameter set previously but not currently are filtered out. Don't use a Yes/No parameter because values for Yes will remain from previous in non-selected elements and you'll have to go though those to reset them rather than just setting a new string to filter with.

Message 3 of 6

yafimski
Contributor
Contributor

@RPTHOMAS108Thanks for your reply. I've been thinking on how to approach this. If I'm not mistaken, you are suggesting to tag a Category based on the Selection, and then filter out the ElementIds that have that tag.

It makes sense, but the generic method for creating the takeoff schedule is:

ViewSchedule CreateMaterialTakeoff(Document document, ElementId categoryId);

 

So for example if I have 20 walls of type Generic_100, and I selected only 5 of them, I'd like to send only those 5 to the schedule, not all 20.

 

What do you think would be the best way to do this or can you clarify this process?

Thanks

0 Likes
Message 4 of 6

RPTHOMAS108
Mentor
Mentor
Accepted solution

After creating the schedule you would have to add a ScheduleFilter

 

ScheduleFilter(ScheduleFieldId, ScheduleFilterType, String)

With ScheduleFilterType = ScheduleFilterType.Equal and String is the Unique GUID string you've set at an instance in time for your selected elements

 

How to obtain ScheduleFieldId for above:

ViewShedule.Definition = ScheduleDefinition class noted below

Seems you have to iterate all fields via ScheduleDefinition.GetField(Int32) and ScheduleDefinition.GetFieldCount

Not sure if index is 0 based or 1 based (index is related to field order in schedule).

 

The .GetField metod returns a ScheduleField object that has a .ParameterID property you can use to match against your target SharedParameterElement. Would be nice if there was a method to get the relationship directly i.e.  .GetField(SharedParameterGUID as GUID) but it seems not to exist,

 

Then you can add the filter via.

ViewSchedule.Definition.AddFilter(ScheduleFilter)

 

When you cycle the selection you need to remove all the filters (ScheduleDefinition.ClearFilters) and add an updated filter.

 

 

 

 

Message 5 of 6

yafimski
Contributor
Contributor

@RPTHOMAS108 

Thanks.

I'm not very familiar with Schedule Filters, but I understand you mean that the selected elements should be filtered in the schedule, based on the unique GUID string right?

But in that case, if I selected 5 walls but gave the GUID to 20 of them based on the wall CategoryId, the schedule will still contain 20 elements.

Not sure I understand how schedule filters can be applied in a way that helps me before placing the elements in the schedule.

 

Did I understand your reply correctly..?

 

Do I need to assign the SharedParameter to the entire Type of wall, and then apply the GUID only to selected instances? That would make more sense right? Just not sure if that's the way to go about it / if it's possible like that.

0 Likes
Message 6 of 6

RPTHOMAS108
Mentor
Mentor

Yes.

 

If you select 5 elements the GUID is added within your new parameter to those five elements and the schedule is filtered to those 5 elements because the filter condition of the schedule is to only show items with that parameter containing that GUID value.

 

If you then select 5 alternative elements then you create a new GUID set the parameter value of those 5 elements to that and update the filters in the schedule (remove all filter and add new filter).