Revit API

Reply
Active Member
rickross96
Posts: 9
Registered: ‎03-04-2010
Message 1 of 2 (517 Views)

Specify Print Setup Name

517 Views, 1 Replies
01-11-2012 01:56 PM

I have written a Drawing Issuing Program in VB.net. So far it works with exporting DWGs and DWFs to specific project folders based on the Central Model location. I am now trying to add a PDF printing routine with great difficulty. We have Acrobat Pro installed so we have the Adobe PDF printer installed on machines. I have a Print Setup in our Project Template called “PDF 42x30 FULL-BLK”. I currently have code that will start printing process, but cannot seem to set the PrintManager.PrintSetup. I found a piece of code that seem to look like what I want but continues to fail. Here is the code that I seem to have trouble with.

 

    Private Sub CreateAndPrintViewSet(ByVal document As Document, ByVal viewSet As ViewSet)

        'Set the print range to the current view

        m_printMgr.PrintRange = Autodesk.Revit.DB.PrintRange.Current

        'Set file name for PDF

        Dim PDFtoFile As String = Path.Combine(m_pdfFloder, m_pdfFileName)

        If Not SetPrintSettings("PDF 42x30 FULL-BLK") Then

            TaskDialog.Show("PrintPDF", "Unable to set Print Settings")

            Return

        End If

        'Set Print Manager to print to File

        m_printMgr.PrintToFile = True

        'Set Print Manager to print to File Name

        m_printMgr.PrintToFileName = PDFtoFile

        'Initailizes Print

        m_printMgr.SubmitPrint()

    End Sub

 

    Public Shared Function SetPrintSettings(ByVal name As String) As Boolean

        MessageBox.Show("Start Getting Names")

        For Each ps As Element In m_activeDoc.PrintSettings

            If ps.Name = name Then

                If m_printMgr.PrintSetup.CurrentPrintSetting Is DirectCast(ps, IPrintSetting) Then

                    Dim trans = New Transaction(m_activeDoc)

                    trans.Start("PDF 42x30 FULL-BLK")

                    m_printMgr.PrintSetup.CurrentPrintSetting = DirectCast(ps, IPrintSetting)

                    trans.Commit()

                    Return True

                End If

                Return True

            End If

        Next

        Return False

    End Function

 

After I get this working, I need to set the Adobe Save As window to the correct location.

ADN Support Specialist
augusto.goncalves
Posts: 341
Registered: ‎04-30-2009
Message 2 of 2 (510 Views)

Re: Specify Print Setup Name

01-12-2012 05:42 AM in reply to: rickross96

Hi,

 

Have you tried the sample at <<Revit SDK>>\Samples\ViewPrinter\CS ?

 

It is similar to want you described.

 

Regards,

Augusto Goncalves

Regards,



Augusto Goncalves
Autodesk Developer Network
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.