Custom printing tool not working in Revit 2014

Custom printing tool not working in Revit 2014

Anonymous
Not applicable
540 Views
3 Replies
Message 1 of 4

Custom printing tool not working in Revit 2014

Anonymous
Not applicable

Hi All,

I created a fairly simple batch printing tool that works fine in Revit 2013 but crashes in 2014 after printing with an "An unrecoverable error has occured..." message box.

 

This is the relevant code (part of a larger class):

 

 

PrintManager printManager = doc.PrintManager;

printManager.PrintRange = PrintRange.Select;

printManager.ViewSheetSetting.SaveAs(Guid.NewGuid().ToString());

printManager.PrintSetup.CurrentPrintSetting.PrintParameters.ZoomType = ZoomType.FitToPage;
printManager.SelectNewPrintDriver(_driverName);  // _driverName is a string property 
printManager.PrintToFile = true;

 

foreach (WinForms.DataGridViewRow row in form.dgvSheets.SelectedRows)
{
    PrintSheet ps = row.DataBoundItem as PrintSheet;  // PrintSheet is a class that wraps ViewSheet
    ViewSheet vs = ps.AssociatedSheet;
    printManager.PrintToFileName = Path.Combine(Destination, ps.NewFileName);


    if (File.Exists(printManager.PrintToFileName))
    {
        if (Overwrite)
            File.Delete(printManager.PrintToFileName);
        else
            continue;
    }
    printManager.Apply();

    bool ok = printManager.SubmitPrint(vs);

}

 

Any ideas?

0 Likes
541 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
Where does it crash ? And did you resolve all the obsolte warnings, could be you are using code that has come obsolete in 2014. (and if that is the case visual studio will throw a warning for it).

0 Likes
Message 3 of 4

Anonymous
Not applicable

Hi Remy,

Thanks for the reply.

It turned out to be the File.Delete() causing some kind of race condition - at least when I removed than part it works fine.

 

Not sure why it worked in 2013 though

 

- Sean

0 Likes
Message 4 of 4

Anonymous
Not applicable
Since File.Delete() belongs to .NET I believe it has something to do with the framework you are using. Can it be that you use a different framework in 2013 then in 2014 ?
0 Likes