Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

one click PDF export journal

Status
Not open for further replies.

tompol74

Mechanical
Mar 15, 2011
7
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
 
Replies continue below

Recommended for you

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
 
Have a look in this thread: thread561-264567
you may find something useful.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor