×
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

one click PDF export journal

one click PDF export journal

one click PDF export journal

(OP)
Hi,

I try to create a journal in VisualBasic to create a pdf file of all sheets of current drawing with one click. I have recorded in NX6 a journal file of export and modified it to set pdf file name same as drawing file. I have problem with the number and the names of drawing sheets. I need to put all sheets into an array "sheets1". In the following example I have 3 sheets: "SHT1", "SHT2", "SHT3" but the number and the names of sheets should be handled automaticaly. Can anyone help me with this?


' NX 6.0.5.3


Option Strict Off
Imports System
Imports NXOpen
imports system.windows.forms


Module NXJournal
Sub Main

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 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.OutputText = PrintPDFBuilder.OutputTextOption.Polylines

printPDFBuilder1.ImageResolution = PrintPDFBuilder.ImageResolutionOption.Medium

printPDFBuilder1.RasterImages = True

printPDFBuilder1.Watermark = ""

Dim sheets1(2) As NXObject

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

Dim drawingSheet2 As Drawings.DrawingSheet = CType(workPart.DrawingSheets.FindObject("SHT2"), Drawings.DrawingSheet)
sheets1(1) = drawingSheet2

Dim drawingSheet3 As Drawings.DrawingSheet = CType(workPart.DrawingSheets.FindObject("SHT3"), Drawings.DrawingSheet)
sheets1(2) = drawingSheet3

printPDFBuilder1.SourceBuilder.SetSheets(sheets1)

Dim path_length As Integer = Len(thesession.Parts.Work.FullPath)

Dim path_trunc As String = Mid(thesession.Parts.Work.FullPath,1,path_length-4)

Dim part_name As String = path_trunc + ".pdf"

printPDFBuilder1.Filename = part_name

Dim nXObject1 As NXObject
nXObject1 = printPDFBuilder1.Commit()

printPDFBuilder1.Destroy()

' ----------------------------------------------
'   Menu: Tools->Journal->Stop Recording
' ----------------------------------------------

End Sub
End Module

RE: one click PDF export journal

You could try this:

    private NXObject[] getDrawingSheets(Part part) throws RemoteException {

        ArrayList sheetList = new ArrayList();

        DrawingSheetCollection sheetCollection = part.drawingSheets();

        for (Iterator it = sheetCollection.iterator(); it.hasNext(); ) {
            sheetList.add(it.next());
        }

        int i=0;

        NXObject[] sheets = new NXObject[sheetList.size()];
        for (Object sheet: sheetList) {
            sheets[i++] = (NXObject)sheet;
            System.err.println("Sheet"+(NXObject)sheet);
        }

        return sheets;
    }


and then call the like:

NXObject[] sheets = getDrawingSheets(this.workPart);
        
instead of:

printPDFBuilder.setSheets(sheets);

Hope this helps!!

Adam
 

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