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: 

Specify Print Setup Name

1 REPLY 1
Reply
Message 1 of 2
rickross96
1351 Views, 1 Reply

Specify Print Setup Name

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.

Tags (3)
1 REPLY 1
Message 2 of 2

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
Twitter @augustomaia
Autodesk Developer Network

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