Crash on TableSectionData.GetTableCellStyle call

Crash on TableSectionData.GetTableCellStyle call

FRFR1426
Collaborator Collaborator
456 Views
2 Replies
Message 1 of 3

Crash on TableSectionData.GetTableCellStyle call

FRFR1426
Collaborator
Collaborator

This code crashes Revit (2015, 2016 and 2017 on Windows 10):

 

[Transaction(TransactionMode.Manual)]
[Regeneration(RegenerationOption.Manual)]
class TestCommand : IExternalCommand
{
    public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
    {
        UIApplication uiApplication = commandData.Application;
        Document document = uiApplication.ActiveUIDocument.Document;
        using (var collector = new FilteredElementCollector(document))
        {
            collector.OfClass(typeof(ViewSchedule));
            foreach (Element element in collector)
            {
                var viewSchedule = (ViewSchedule) element;
                TableData tableData = viewSchedule.GetTableData();
                for (int sectionIdx = 0; sectionIdx < tableData.NumberOfSections; sectionIdx++)
                {
                    TableSectionData sectionData = tableData.GetSectionData(sectionIdx);
                    for (int rowIdx = sectionData.FirstRowNumber; rowIdx <= sectionData.LastRowNumber; rowIdx++)
                    {
                        for (int colIdx = sectionData.FirstColumnNumber; colIdx < sectionData.LastColumnNumber; colIdx++)
                        {
                            TableCellStyle cellStyle = sectionData.GetTableCellStyle(rowIdx, colIdx); // <- Boom!!!
                        }
                    }
                }
            }
        }
        return Result.Succeeded;
    }
}

Steps to reproduce:

 

  1. Open a file (rac_advanced_sample_project.rvt for example);
  2. Launch the command ;
  3. Revit crashes with a 'System.AccessViolationException' in RevitDBAPI.dll.
Maxence DELANNOY
Manager
Add-ins development for Autodesk software products
http://wiip.fr
0 Likes
Accepted solutions (1)
457 Views
2 Replies
Replies (2)
Message 2 of 3

FRFR1426
Collaborator
Collaborator

Tried on another computer, same result.

Maxence DELANNOY
Manager
Add-ins development for Autodesk software products
http://wiip.fr
0 Likes
Message 3 of 3

FRFR1426
Collaborator
Collaborator
Accepted solution

OK, it's a Revit bug (issue REVIT-92722).

Maxence DELANNOY
Manager
Add-ins development for Autodesk software products
http://wiip.fr
0 Likes