Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Custom printing tool not working in Revit 2014

3 REPLIES 3
Reply
Message 1 of 4
sean
413 Views, 3 Replies

Custom printing tool not working in Revit 2014

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?

Tags (2)
3 REPLIES 3
Message 2 of 4
R.van.den.Bor
in reply to: sean

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).

Kind regards,
Remy van den Bor
ICN Solutions B.V.
Liked this post or found it usefull, don't forget the Kudo It won't hurt (at least not me).
Message 3 of 4
sean
in reply to: R.van.den.Bor

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

Message 4 of 4
R.van.den.Bor
in reply to: sean

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 ?
Kind regards,
Remy van den Bor
ICN Solutions B.V.
Liked this post or found it usefull, don't forget the Kudo It won't hurt (at least not me).

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community