Printing Settings

Printing Settings

BrentBurgess1980
Collaborator Collaborator
1,424 Views
4 Replies
Message 1 of 5

Printing Settings

BrentBurgess1980
Collaborator
Collaborator

Hi all,

 

When I use this code below, my printing is not producing any different output, even if I make changes to zoom, colour etc. Is there something I am missing or not setting properly?

    [Transaction(TransactionMode.Manual)]
    public class PrintSettingsCommand : IExternalCommand
        {
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
            {
            Document OpenDoc = App.CurrentDocument;
            PrintManager printManager = OpenDoc.PrintManager;

            printManager.PrintSetup.CurrentPrintSetting = printManager.PrintSetup.InSession;
            printManager.SelectNewPrintDriver(App.BASPalette.cboPrinter.SelectedItem as string);
            printManager.PrintToFile = true;
            printManager.PrintRange = PrintRange.Select;
            printManager.PrintToFileName = string.Format(@"C:\PDF\{0}.pdf", OpenDoc.ProjectInformation.Name);

            IPrintSetting printSettings = printManager.PrintSetup.CurrentPrintSetting;
            ViewSheetSetting viewSheetSetting = printManager.ViewSheetSetting;
            ViewSet viewSet = new ViewSet();

            for (int i = 0; i < App.BASPalette.lvwSheets.SelectedItems.Count; i++)
                {
                WSPSheet sheet = App.BASPalette.lvwSheets.SelectedItems[i] as WSPSheet;
                if (sheet != null)
                    {
                    if (sheet.View.CanBePrinted)
                        {
                        viewSet.Insert(sheet.View);
                        }
                    }
                }

            printSettings.PrintParameters.PageOrientation = PageOrientationType.Landscape;
            printSettings.PrintParameters.PaperSize = App.BASPalette.cboPaperSize.SelectedItem as PaperSize;
            printSettings.PrintParameters.ZoomType = ZoomType.Zoom;
            printSettings.PrintParameters.Zoom = 100;
            printSettings.PrintParameters.ColorDepth = ColorDepthType.GrayScale;

            using (Transaction transaction = new Transaction(OpenDoc))
                {
                transaction.Start("Set in-session views");
                viewSheetSetting.InSession.Views = viewSet;
                transaction.Commit();
                }

            printManager.PrintSetup.CurrentPrintSetting = printSettings;

            printManager.CombinedFile = true;
            printManager.Apply();
            OpenDoc.Print(viewSet, true);


            return Result.Succeeded;
            }
        }

 

0 Likes
Accepted solutions (1)
1,425 Views
4 Replies
Replies (4)
Message 2 of 5

jeremytammik
Autodesk
Autodesk

Have you searched this forum for existing answers before raising your question?

 

Here is an issue that was successfully resolved that sounds pretty similar to yours:

 

https://forums.autodesk.com/t5/revit-api-forum/viewsheet-set-to-be-printed-setting-problem/m-p/88231...

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 3 of 5

BrentBurgess1980
Collaborator
Collaborator
0 Likes
Message 4 of 5

BrentBurgess1980
Collaborator
Collaborator
Accepted solution

I managed to take the viewprinter from the SDK and modify to suit my requirements.

0 Likes
Message 5 of 5

luis7SJJ3
Contributor
Contributor

What was the solution?

0 Likes