I have recently setup a new journal with the code below from this comment, http://nxjournaling.com/comment/4868#comment-4868. Is it possible to add sorting to this? When I use this to export, the sheets are not sorted numerically per sheet name/number. Using NX9.
Imports System
Imports NXOpen
Module NXJournal
Sub Main (ByVal args() As String)
Dim theSession As NXOpen.Session = NXOpen.Session.GetSession()
Dim workPart As NXOpen.Part = theSession.Parts.Work
Dim displayPart As NXOpen.Part = theSession.Parts.Display
Dim printPDFBuilder1 As NXOpen.PrintPDFBuilder = Nothing
printPDFBuilder1 = workPart.PlotManager.CreatePrintPdfbuilder()
'Get part number attribute (drawing must be work part)
Dim partnumber = workPart.GetUserAttribute("DB_PART_NO", NXObject.AttributeType.String, -1)
Dim partnumberstring = partnumber.StringValue
'Parameters
printPDFBuilder1.Relation = NXOpen.PrintPDFBuilder.RelationOption.Manifestation
printPDFBuilder1.DatasetType = "PDF"
printPDFBuilder1.NamedReferenceType = "PDF_Reference"
printPDFBuilder1.Scale = 1.0
printPDFBuilder1.Colors = NXOpen.PrintPDFBuilder.Color.BlackOnWhite
printPDFBuilder1.Size = NXOpen.PrintPDFBuilder.SizeOption.ScaleFactor
printPDFBuilder1.Units = NXOpen.PrintPDFBuilder.UnitsOption.English
printPDFBuilder1.RasterImages = True
printPDFBuilder1.ImageResolution = NXOpen.PrintPDFBuilder.ImageResolutionOption.Medium
printPDFBuilder1.Assign()
'Set sheets to an array of all drawing sheets
printPDFBuilder1.SourceBuilder.SetSheets(workpart.DrawingSheets.ToArray)
'Get part number attribute (drawing must be work part) and set as string
Dim partnumber = workPart.GetUserAttribute("DB_PART_NO", NXObject.AttributeType.String, -1)
Dim partnumberstring = partnumber.StringValue
'Assign Dataset name as part number
printPDFBuilder1.DatasetName = partnumberstring
Dim nXObject1 As NXOpen.NXObject = Nothing
nXObject1 = printPDFBuilder1.Commit()
printPDFBuilder1.Destroy()
End Sub
End Module
re: pdf sorting
If you add all the sheets to a list, you can then sort the list however you like and process the sheets in that order.
http://www.nxjournaling.com/content/sort-list-nx-objects
The PDF exporter class has an option to sort the sheets (using the technique from the previous link), but it doesn't export them to a TC dataset. It is a lot of code to look through, but if you are interested, you can find it here:
http://www.nxjournaling.com/content/pdf-exporter-class