InsertSortGroupField not completing???

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi there,
I am trying to order my sorting and grouping in the Revit API. the transaction completes fine when i use the AddSortGroupField method but this always puts Type before Category when sorting. When I use the InsertSortGroupField method the transaction does not complete?
Snippet of the code below, Can anyone help?
if (schedulableField.FieldType == ScheduleFieldType.Instance)
{
//Add a new schedule field to the view schedule by using the SchedulableField as argument of AddField method of Autodesk.Revit.DB.ScheduleDefinition class.
String fieldname = schedulableField.GetName(document);
if (fieldname == "Type")
{
ScheduleField fieldType = schedule.Definition.InsertField(schedulableField,1);
fieldType.GridColumnWidth = 4.0 / 12;
fieldType.HorizontalAlignment = ScheduleHorizontalAlignment.Left;
ScheduleSortGroupField TypeGroupField = new ScheduleSortGroupField(fieldType.FieldId);
schedule.Definition.InsertSortGroupField(TypeGroupField,1);
TypeGroupField.ShowHeader = false;
}
if (fieldname == "Category")
{
ScheduleField fieldCat = schedule.Definition.InsertField(schedulableField,0);
fieldCat.GridColumnWidth = 4.0 / 12;
fieldCat.HorizontalAlignment = ScheduleHorizontalAlignment.Left;
ScheduleSortGroupField CatGroupField = new ScheduleSortGroupField(fieldCat.FieldId);
schedule.Definition.InsertSortGroupField(CatGroupField,0);
CatGroupField.ShowHeader = true;
fieldCat.IsHidden = true;
}
schedule.Definition.IsItemized = false;
schedule.Definition.ShowHeaders = true;
}
//Judge if the FieldType is ScheduleFieldType.Count.
if (schedulableField.FieldType == ScheduleFieldType.Count)
{
schedule.Definition.InsertField(ScheduleFieldType.Count,3);
}
}