• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Autodesk Revit API

    Reply
    Active Member
    Posts: 8
    Registered: ‎03-04-2010

    Specify Print Setup Name

    339 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.

    Please use plain text.
    ADN Support Specialist
    Posts: 150
    Registered: ‎04-30-2009

    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
    Please use plain text.