Idle 이벤트 핸들러가있는 Revit API를 사용하여 Revit 2017에서 PDF 인쇄 프로세스를 자동화하려고합니다. OpenDocumentFile 메서드를 사용하여 Revit 문서를 열고 어디서나 ActiveUIDocument를 사용하지 않습니다. 이 프로세스는 잘못된 연산 예외를 생성하고 있습니다. 왜 예외를 제공하는지 또는 Revit API를 사용하여 허용되는지 여부는 확실하지 않습니다. 도와주세요. 감사.Revit to Pdf Conversion
저널 출력 : 뒤에
' 1:< 0 <-pushSettingsIntoDriver
' C 27-Sep-2016 14:45:22.641; 1:< ExportToRequestedFormat() : Pdf Print Exception : InvalidOperationExceptionAt least one view from the view set could not be printed.
' at Autodesk.Revit.DB.Document.Print(ViewSet views, View viewTemplate, Boolean useCurrentPrintSettings)
' at Autodesk.Revit.DB.Document.Print(ViewSet views, Boolean useCurrentPrintSettings)
' at RevitCommandListener.RevitCommandListenerService.ExportToRequestedFormat(UIApplication uiapp)
코드 : IsPrintable 필드에 추가
using (FilteredElementCollector viewCollector = new FilteredElementCollector(doc))
{
ViewSet set = new ViewSet();
ElementClassFilter viewFilter = null;
PrintManager pm = PrinterDriverSettings.GetPrintManager(doc, _ifcSaveFile, PrinterDriver.Bullzip);
switch (_pdfExportSetting)
{
case PDFExportOptions.SheetsOnly:
viewFilter = new ElementClassFilter(typeof(Autodesk.Revit.DB.ViewSheet));
viewCollector.WherePasses(viewFilter);
foreach (Autodesk.Revit.DB.ViewSheet vw in viewCollector)
{
if (vw.CanBePrinted && !vw.IsTemplate)
set.Insert(vw);
}
break;
case PDFExportOptions.ViewsOnly:
viewFilter = new ElementClassFilter(typeof(Autodesk.Revit.DB.View));
viewCollector.WherePasses(viewFilter);
foreach (Autodesk.Revit.DB.View vw in viewCollector)
{
if (vw.CanBePrinted && !vw.IsTemplate && !(vw.GetType() == typeof(ViewSheet))) //Skip sheets
set.Insert(vw);
}
break;
case PDFExportOptions.ViewsAndSheets:
viewFilter = new ElementClassFilter(typeof(Autodesk.Revit.DB.View));
viewCollector.WherePasses(viewFilter);
foreach (Autodesk.Revit.DB.View vw in viewCollector)
{
if (vw.CanBePrinted && !vw.IsTemplate)
set.Insert(vw);
}
break;
case PDFExportOptions.Sections:
viewFilter = new ElementClassFilter(typeof(Autodesk.Revit.DB.ViewSection));
viewCollector.WherePasses(viewFilter);
foreach (Autodesk.Revit.DB.ViewSection vw in viewCollector)
{
if (vw.CanBePrinted && && !vw.IsTemplate !(vw.ViewType == ViewType.Elevation))
set.Insert(vw);
}
break;
case PDFExportOptions.Elevations:
viewFilter = new ElementClassFilter(typeof(Autodesk.Revit.DB.ViewSection));
viewCollector.WherePasses(viewFilter);
foreach (Autodesk.Revit.DB.ViewSection vw in viewCollector)
{
if (vw.CanBePrinted && !vw.IsTemplate && vw.ViewType == ViewType.Elevation)
{
set.Insert(vw);
}
}
break;
case PDFExportOptions.Schedules:
viewFilter = new ElementClassFilter(typeof(ViewSchedule));
viewCollector.WherePasses(viewFilter);
foreach (ViewSchedule vw in viewCollector)
{
if (vw.CanBePrinted && !vw.IsTemplate)
set.Insert(vw);
}
break;
}
if (_pdfExportSetting != PDFExportOptions.None && set.Size > 0)
{
Transaction tr = new Transaction(doc, "tr_pdf_print");
try
{
tr.Start();
doc.Print(set, true);
tr.Commit();
}
catch(Autodesk.Revit.Exceptions.InvalidOperationException iopex)
{
uiapp.Application.WriteJournalComment("ExportToRequestedFormat() : Pdf Print Exception : InvalidOperationException" + iopex.Message + Environment.NewLine + iopex.StackTrace, true);
}
catch(Autodesk.Revit.Exceptions.ArgumentNullException argsex)
{
uiapp.Application.WriteJournalComment("ExportToRequestedFormat() : Pdf Print Exception : ArgumentNullException" + argsex.Message + Environment.NewLine + argsex.StackTrace, true);
}
catch(Autodesk.Revit.Exceptions.ArgumentException arex)
{
uiapp.Application.WriteJournalComment("ExportToRequestedFormat() : Pdf Print Exception : ArgumentException" + arex.Message + Environment.NewLine + arex.StackTrace, true);
}
catch(Autodesk.Revit.Exceptions.ApplicationException appex)
{
uiapp.Application.WriteJournalComment("ExportToRequestedFormat() : Pdf Print Exception : ApplicationException" + appex.Message + Environment.NewLine + appex.StackTrace, true);
}
finally
{
set.Dispose();
viewFilter.Dispose();
viewCollector.Dispose();
pm.Dispose();
tr.Dispose();
}
}
제안 해 주셔서 감사합니다. 템플릿에 대한 점검을 포함하도록 내 질문을 편집했지만 효과가 없습니다. 그밖에 실종 된 물건이 있습니까? – amit
초점을 맞추기 만하면 _pdfExportSetting의 모든 경우에 실패합니까? 또는 단지 특정 것들? – Matt
특정 경우에 실패합니다. – amit