×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

NX9 - Export Entire Assembly to a single PDF?
3

NX9 - Export Entire Assembly to a single PDF?

NX9 - Export Entire Assembly to a single PDF?

(OP)
Someone needs to export his entire assembly to a PDF file, but they want it all to end up on one PDF file. We can do these one at a time and append them but that will take forever. Is there a way to batch PDF an assembly to one PDF file?

As stated in the title, this is NX9.
Our model and drafting is in the same files, if that makes a difference.
This is an assembly with the details as separate part files and brought in as components.


Thankyou for any help anyone can offer.

RE: NX9 - Export Entire Assembly to a single PDF?

PDFs of the model or drawings?
With some programming/scripting you could possibly cycle through al of the component files in the drafting application and print the PDFs, but the would be individual files. These could then be combined by the script.

"Wildfires are dangerous, hard to control, and economically catastrophic."

Ben Loosli

RE: NX9 - Export Entire Assembly to a single PDF?

(OP)
They definitely need the drawings from the drafting side.

As for the rest of what you said, it made little sense to me. Sorry.

RE: NX9 - Export Entire Assembly to a single PDF?

Manually select all required sheets before exporting to PDF, hope this what you are looking for. Later you may built script to automate the process.

RE: NX9 - Export Entire Assembly to a single PDF?

switch to drafting go to file->Export->PDF in first window select required sheets or you can arrange sheet sequence in which order you want. make sure select required sheets after arranging. Select file browser and locate the file. All sheets will be in one file

RE: NX9 - Export Entire Assembly to a single PDF?

(OP)
Thanks for the help and I do appreciate it, but I think either my needs are not understood or I am misunderstanding something in the answers.

This looks like it does the PDF for the assembly drawings. However, on this occasion, our customer wants everything on one PDF. Including the details drafting sheets. So if an assembly has 6 make details in it, we will needs the assembly drafting sheets, the BOMs, and the drafting sheets for all 6 details to show up in one PDF.

RE: NX9 - Export Entire Assembly to a single PDF?

I You wanna export all sheets of drawing You have to select all of them. Look at my attached picture. In this example I have 2 sheets, and I selected them.



You can always use journal to do the job for You.
Here is my personalized journal to export PDF. It create folder "PDF" in place where part file is.

CODE

Option Strict Off
Imports System
Imports System.IO
Imports System.Collections
Imports System.Windows.Forms
Imports System.Windows.Forms.MessageBox
Imports NXOpen
Imports NXOpen.UF
 
Module NXJournal
 
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display
 
'**********************************************************
 
Sub Main
 
Dim dwgs As Drawings.DrawingSheetCollection
dwgs = workPart.DrawingSheets
Dim sheet As Drawings.DrawingSheet
Dim i As Integer
Dim pdfFile As String
Dim currentPath As String
Dim currentFile As String
Dim exportFile As String
Dim partUnits As Integer
Dim strOutputFolder As String
Dim strRevision As String
Dim rspFileExists
Dim rspAdvancePrint
 
'determine if we are running under TC or native
Dim IsTcEng As Boolean = False
Dim UFSes As UFSession = UFSession.GetUFSession()
UFSes.UF.IsUgmanagerActive(IsTcEng)
 
partUnits = displayPart.PartUnits
'0 = inch
'1 = metric
 
If IsTcEng Then
   currentFile = workPart.GetStringAttribute("DB_PART_NO")
   strRevision = workPart.GetStringAttribute("DB_PART_REV")
 
Else 'running in native mode
   'currentFile = GetFilePath() & GetFileName() & ".prt"
   currentPath = GetFilePath()
   currentFile = GetFileName()
 
   Try
       strRevision = workPart.GetStringAttribute("REVISION")
       strRevision = Trim(strRevision)
   Catch ex As Exception
       strRevision = ""
   End Try
End If
exportFile = currentFile
 
'strOutputFolder = OutputPath()
strOutputFolder = CurrentPath + "PDF"

'if we don't have a valid directory (ie the user pressed 'cancel') exit the journal

If (Not System.IO.Directory.Exists(strOutputFolder)) Then
		System.IO.Directory.CreateDirectory(strOutputFolder)
End If


strOutputFolder = strOutputFolder & "\"
 
'rspAdvancePrint = MessageBox.Show("Add advance print watermark?", "Add Watermark?", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
 
Dim shts As New ArrayList()
For Each sheet in dwgs
shts.Add(sheet.Name)
Next
shts.Sort()
 
i = 0
Dim sht As String
For Each sht in shts
 
   For Each sheet in dwgs
       If sheet.name = sht Then
           i = i + 1
 
           If rspAdvancePrint = vbyes Then
               pdfFile = strOutputFolder & exportFile & "_advance" & ".pdf"
           Else
               If strRevision <> "" Then
                   pdfFile = strOutputFolder & exportFile & "_" & strRevision & ".pdf"
               Else
                   pdfFile = strOutputFolder & exportFile & ".pdf"
               End If
           End If
 
           'the pdf export uses 'append file', if we are on sheet 1 make sure the user wants to overwrite
           'if the drawing is multisheet, don't ask on subsequent sheets

           If i = 1 Then
               If File.Exists(pdfFile) Then
                   rspFileExists = msgbox("The file: '" & pdfFile & "' already exists; overwrite?", vbyesno + vbquestion)
                   If rspFileExists = vbYes Then
                       Try
                           File.Delete(pdfFile)
                       Catch ex As Exception
                           msgbox(ex.message & vbcrlf & "Journal exiting", vbcritical + vbokonly, "Error")
                           Exit Sub
                       End Try
                   Else
                       'msgbox("journal exiting", vbokonly)
                       Exit Sub
                   End If
               End If
           End If
 
           'update any views that are out of date
           theSession.Parts.Work.DraftingViews.UpdateViews(Drawings.DraftingViewCollection.ViewUpdateOption.OutOfDate, sheet)
 
            Try
               ExportPDF(sheet, pdfFile, partUnits, rspAdvancePrint)
           Catch ex As exception
               msgbox("Error occurred in PDF export" & vbcrlf & ex.message & vbcrlf & "journal exiting", vbcritical + vbokonly, "Error")
               Exit Sub
           End Try
           Exit For
       End If
   Next
 
Next
 
   If i = 0 Then
       MessageBox.Show("This part has no drawing sheets to export", "PDF export failure", MessageBoxButtons.ok, MessageBoxIcon.Warning)
   Else
       MessageBox.Show("Exported: " & i & " sheet(s) to pdf file" & vbcrlf & pdfFile, "PDF export success", MessageBoxButtons.ok, MessageBoxIcon.Information)
   End If
 
End Sub
'**********************************************************
 
Function GetFileName()
   Dim strPath As String
   Dim strPart As String
   Dim pos As Integer
 
   'get the full file path
   strPath = displayPart.fullpath
   'get the part file name
   pos = InStrRev(strPath, "\")
   strPart = Mid(strPath, pos + 1)
 
   strPath = Left(strPath, pos)
   'strip off the ".prt" extension
   strPart = Left(strPart, Len(strPart) - 4)
 
   GetFileName = strPart
End Function
'**********************************************************
 
Function GetFilePath()
   Dim strPath As String
   Dim strPart As String
   Dim pos As Integer
 
   'get the full file path
   strPath = displayPart.fullpath
   'get the part file name
   pos = InStrRev(strPath, "\")
   strPart = Mid(strPath, pos + 1)
 
   strPath = Left(strPath, pos)
   'strip off the ".prt" extension
   strPart = Left(strPart, Len(strPart) - 4)
 
   GetFilePath = strPath
End Function
'**********************************************************
 
Sub ExportPDF(dwg As Drawings.DrawingSheet, outputFile As String, units As Integer, advancePrint As Integer)
 
   Dim printPDFBuilder1 As PrintPDFBuilder
 
   printPDFBuilder1 = workPart.PlotManager.CreatePrintPdfbuilder()
   printPDFBuilder1.Scale = 1.0
   printPDFBuilder1.Action = PrintPDFBuilder.ActionOption.Native
   printPDFBuilder1.Colors = PrintPDFBuilder.Color.BlackOnWhite
   printPDFBuilder1.Size = PrintPDFBuilder.SizeOption.ScaleFactor
   If units = 0 Then
       printPDFBuilder1.Units = PrintPDFBuilder.UnitsOption.English
   Else
       printPDFBuilder1.Units = PrintPDFBuilder.UnitsOption.Metric
   End If
   printPDFBuilder1.XDimension = dwg.height
   printPDFBuilder1.YDimension = dwg.length
   printPDFBuilder1.OutputText = PrintPDFBuilder.OutputTextOption.Polylines
   printPDFBuilder1.RasterImages = True
   printPDFBuilder1.ImageResolution = PrintPDFBuilder.ImageResolutionOption.Medium
   printPDFBuilder1.Append = True
   If advancePrint = vbyes Then
       printPDFBuilder1.AddWatermark = True
       printPDFBuilder1.Watermark = "ADVANCE PRINT NOT TO BE USED FOR PRODUCTION " & Today
   Else
       printPDFBuilder1.AddWatermark = False
       printPDFBuilder1.Watermark = ""
   End If
 
   Dim sheets1(0) As NXObject
   Dim drawingSheet1 As Drawings.DrawingSheet = CType(dwg, Drawings.DrawingSheet)
 
   sheets1(0) = drawingSheet1
   printPDFBuilder1.SourceBuilder.SetSheets(sheets1)
 
   printPDFBuilder1.Filename = outputFile
 
   Dim nXObject1 As NXObject
   nXObject1 = printPDFBuilder1.Commit()
 
   printPDFBuilder1.Destroy()
 
End Sub
'**********************************************************
 
End Module 


With best regards
Michael

RE: NX9 - Export Entire Assembly to a single PDF?

3
Buy Adobe Acrobat.

RE: NX9 - Export Entire Assembly to a single PDF?

Below is a link to some code that I put together some months ago. It seems to work well on my small test assemblies, but some users with large assemblies have reported blank sheets appearing in the output. Be sure to double check the output...

monolithic pdf

www.nxjournaling.com

RE: NX9 - Export Entire Assembly to a single PDF?

(OP)
Niedzviedz, what you picture describes will only give me the sheets in the main assembly. It will not create a PDF of all of the detail components as well and add them as part of the same PDF. I am not good enough with code to read your code and know what it will do, but I have to assume that if you are misunderstanding what I want in the picture, the code would not be any different. If an assembly has a clamp detail, two block details and a bracket detail, along with 10 standard components, I need the PDF to have the drawing sheets from the assembly as well as the drawing sheets for the four details in the one PDF.

Ivan, .... If only this world was set up where my bosses would buy every program I wanted from them. clown

Cowski, I will look at the link.

Again, I do thank all of you for your time and help. :)

RE: NX9 - Export Entire Assembly to a single PDF?

Alternately, if you have the individual pdf files, you can combine them with the cgm2pdf.exe that ships with NX (no need to buy Acrobat).

www.nxjournaling.com

RE: NX9 - Export Entire Assembly to a single PDF?

(OP)
Hey cowski

Your code did the job with one problem, and I am not sure how easy that would be to fix. I had the guy who needed it run this journal on a small assembly to test it and it worked, but the sheets were out of order. The assemblies drawing sheets were together but they were out of order, then the detail sheets were out of order as well.

However, I do want to be clear that this job has lost its importance at this time because the gentleman who needed this ran PDFs the normal way for the assembly, then did the details individually and appended them to the assembly PDF. I was trying to find a way to make the job easier but he went ahead and did it the hard way because it is not the usual job for us. So if you were to address the code putting the sheets out of order, it would be more for just fixing the problem than for what is needed at this time. I just wanted to let you know so you don't spend time on it thinking it was still needed.

But if you ever do get free time in the future and dig into it. I wouldn't mind having that in case anything else comes up in the future like this job. lol Just no hurry on it.

RE: NX9 - Export Entire Assembly to a single PDF?

Depends on what you mean by "out of order". What order did you expect and what did you get?

www.nxjournaling.com

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources