Showing results for 
Search instead for 
Do you mean 
Reply

Export STEP and PDF with an Easy button

[ Edited ]

We use the master model approach for drawings (a part file with a separate drawing file) within Teamcenter. We'd like to be able to simultaneously (or with on click) export a pdf of the drawing, and a STEP of the model, using a custom journal or equivalent. Is this possible? As you may infer, I am relatively new to NX and this community.

 

Thanks,

 

Adam

1 REPLY

Re: Export STEP and PDF with an Easy button

Hello @ah3,

Yes,It's possible. Record a journal and It will work. You have to change the current file to workpart.fullpath.

Please find the code below which will work for PDF.

Similarly you can do for STEP as well.

 

Regards,

Abhi

 

Code-

 

Option Strict Off
Imports System
Imports System.IO
Imports NXOpen

Module NXJournal
Sub Main (ByVal args() As String) 

Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work

Dim displayPart As Part = theSession.Parts.Display


        ' ----------------------------------------------
        '   Menu: File->Export->PDF...
        ' ----------------------------------------------
        Dim markId1 As Session.UndoMarkId
        markId1 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Start")

        Dim printPDFBuilder1 As PrintPDFBuilder
        printPDFBuilder1 = workPart.PlotManager.CreatePrintPdfbuilder()

        printPDFBuilder1.Scale = 1.0

        printPDFBuilder1.Colors = PrintPDFBuilder.Color.BlackOnWhite

        printPDFBuilder1.Size = PrintPDFBuilder.SizeOption.ScaleFactor

        printPDFBuilder1.Units = PrintPDFBuilder.UnitsOption.English

        printPDFBuilder1.XDimension = 8.5

        printPDFBuilder1.YDimension = 11.0

        printPDFBuilder1.RasterImages = True

        theSession.SetUndoMarkName(markId1, "Export PDF Dialog")

        Dim markId2 As Session.UndoMarkId
        markId2 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Export PDF")

        theSession.DeleteUndoMark(markId2, Nothing)

        Dim markId3 As Session.UndoMarkId
        markId3 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Export PDF")

        printPDFBuilder1.Watermark = ""

        Dim sheets1(0) As NXObject
        Dim drawingSheet1 As Drawings.DrawingSheet = CType(workPart.DrawingSheets.FindObject("S01"), Drawings.DrawingSheet)

        sheets1(0) = drawingSheet1
        printPDFBuilder1.SourceBuilder.SetSheets(sheets1)

        printPDFBuilder1.Filename = Path.GetDirectoryName(workPart.FullPath) & "\" & Path.GetFileNameWithoutExtension(workPart.FullPath) & ".pdf"
        Dim nXObject1 As NXObject
        nXObject1 = printPDFBuilder1.Commit()

        theSession.DeleteUndoMark(markId3, Nothing)

        theSession.SetUndoMarkName(markId1, "Export PDF")

        printPDFBuilder1.Destroy()

        theSession.DeleteUndoMark(markId1, Nothing)

End Sub
End Module