InsertSortGroupField not completing???

InsertSortGroupField not completing???

Anonymous
Not applicable
406 Views
1 Reply
Message 1 of 2

InsertSortGroupField not completing???

Anonymous
Not applicable

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);
                }
                
               }

0 Likes
407 Views
1 Reply
Reply (1)
Message 2 of 2

augusto.goncalves
Alumni
Alumni
Could not immediately spot anything wrong here... but are the indexes called at the correct order? (when you InsertField, the second parameter, index)

Also, when you say "transaction does not complete", does it throw any exception? Any kind of error message?
Regards,



Augusto Goncalves
Twitter @augustomaia
Autodesk Developer Network
0 Likes