printManager.PrintRange = PrintRange.Select;
printManager.Apply();
printManager.SelectNewPrintDriver(ExternalApplication.options.PrinterName);
printManager.Apply();
if (printManager.IsVirtual == VirtualPrinterType.AdobePDF)
{
printManager.CombinedFile = true;
printManager.Apply();
}
string viewSheetSettingName = string.Format("ViewSheet {0}", nowTime/*viewSheet.SheetNumber*/);
ViewSheetSetting viewSheetSetting = printManager.ViewSheetSetting;
ViewSet viewSet = new ViewSet();
viewSet.Insert(viewSheet);
viewSheetSetting.CurrentViewSheetSet.Views = viewSet;
viewSheetSetting.SaveAs(viewSheetSettingName);
printManager.Apply();
XYZ margins = new XYZ(6, 4, 0);
margins = Utils.ConvertMillimetresToInches(margins);
PrintSetup printSetup = printManager.PrintSetup;
IPrintSetting printSetting = printSetup.CurrentPrintSetting;
printSetting.PrintParameters.ColorDepth = ColorDepthType.BlackLine;//добавить список или переключатель для выбора ColorDepthType;
printSetting.PrintParameters.HiddenLineViews = HiddenLineViewsType.RasterProcessing;// = HiddenLineViewsType.VectorProcessing;
printSetting.PrintParameters.HideCropBoundaries = true;
printSetting.PrintParameters.HideReforWorkPlanes = true;
printSetting.PrintParameters.HideScopeBoxes = true;
printSetting.PrintParameters.HideUnreferencedViewTags = false;
printSetting.PrintParameters.PaperPlacement = PaperPlacementType.Margins;
printSetting.PrintParameters.MarginType = MarginType.UserDefined;
printSetting.PrintParameters.UserDefinedMarginX = margins.X;
printSetting.PrintParameters.UserDefinedMarginY = margins.Y;
printSetting.PrintParameters.RasterQuality = RasterQualityType.High;
printSetting.PrintParameters.ZoomType = ZoomType.Zoom;
printSetting.PrintParameters.Zoom = 100;
printSetting.PrintParameters.PageOrientation = formatName.IndexOf("h", StringComparison.OrdinalIgnoreCase) >= 0 ? PageOrientationType.Landscape : PageOrientationType.Portrait;
if (ExternalApplication.options.InversePageOrientation)
printSetting.PrintParameters.PageOrientation = printSetting.PrintParameters.PageOrientation == PageOrientationType.Landscape ? PageOrientationType.Portrait : PageOrientationType.Landscape;
bool paperSizeFound = false;
string paperSizeName = "";
foreach (PaperSize paperSize in printManager.PaperSizes)
{
paperSizeName = paperSize.Name;
if (ExternalApplication.options.InversePageFormat)
paperSizeName = ReplaceFormatChar(paperSizeName);
else if (ExternalApplication.options.InversePageFormatOnLandscape && printSetting.PrintParameters.PageOrientation == PageOrientationType.Landscape)
paperSizeName = ReplaceFormatChar(paperSizeName);
if (string.Equals(paperSizeName, formatName, StringComparison.OrdinalIgnoreCase))
{
printSetting.PrintParameters.PaperSize = paperSize;
paperSizeFound = true;
break;
}
}
if (!paperSizeFound)
{
TaskDialog.Show("Revit", string.Format("Не найден формат {0} для принтера {1} на листе {2}!", formatName, ExternalApplication.options.PrinterName, viewSheet.SheetNumber), TaskDialogCommonButtons.Close);
return result;
}
string setupName = string.Format("Setting {0}", nowTime);
printSetup.SaveAs(setupName);
printManager.Apply();
FilteredElementCollector printSettings = new FilteredElementCollector(doc).OfClass(typeof(PrintSetting));
foreach (PrintSetting ps in printSettings)
{
if (ps.Name == setupName)
{
doc.PrintManager.PrintSetup.CurrentPrintSetting = ps;
doc.PrintManager.PrintSetup.Save();
break;
}
}
printManager.SubmitPrint();
//printManager.SubmitPrint(viewSheet);
//printManager.Apply();
viewSheetSetting.Delete();