Need Help Improving Journal

Hello,

I have a journal I found that is working fairly well but there is one improvement I am trying to make to it. This journal is for PDF export of every component in an open assembly. The journal walks through the assembly makes the component displayed, Updates views, exports pdf of sheet if it exists, moves on to next component.

I would like to modify the journal to Hide all components after it makes a component displayed. Then update views, export pdf.

Any help would be greatly appreciated.

Thank you,
JS

Option Strict Off
Imports System
Imports System.IO
Imports System.Collections.Generic
Imports System.Windows.Forms
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.Assemblies

Module Module1

Dim theSession As Session = Session.GetSession

Sub Main()

If IsNothing(theSession.Parts.Display) Then
MessageBox.Show("Active Part Required", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Return
End If

Dim lw As ListingWindow = theSession.ListingWindow
lw.Open()

Dim workPart As Part = theSession.Parts.Work

Dim myAsmInfo As New NXJ_Assembly_info
myAsmInfo.Part = workPart

Dim myPdfExporter As New NXJ_PdfExporter
myPdfExporter.PickExportFolder()

myPdfExporter.Part = workPart
Try
myPdfExporter.Commit()
Catch ex As NXException

End Try

For Each tempPart As Part In myAsmInfo.AllUniqueParts
myPdfExporter.Part = tempPart

ChangeDisplayPart(tempPart)

Try
myPdfExporter.Commit()
Catch ex As Exception
MessageBox.Show("Error:" & ControlChars.CrLf & ex.GetType.ToString & " : " & ex.Message, "PDF export error", MessageBoxButtons.OK, MessageBoxIcon.Error)

End Try

Next

ChangeDisplayPart(workPart)
myPdfExporter = Nothing

End Sub

Sub ChangeDisplayPart(ByVal newPart As Part)

Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Change Display Part")

Dim partLoadStatus1 As PartLoadStatus
Dim status1 As PartCollection.SdpsStatus
status1 = theSession.Parts.SetDisplay(newPart, False, False, partLoadStatus1)

partLoadStatus1.Dispose()

End Sub

End Module

*Note: I removed the class code from the original post to keep it at a reasonable length. If anyone is interested, the class code can be found here:
http://nxjournaling.com/content/pdf-exporter-class

I'm not sure what you mean by "hide all components after it makes a component displayed". Are there components on the drawing that you need to hide? Or are they showing up somewhere else?

What I mean is we have a water plate for example that has bolts, orings, other components that we don't want shown on the prints. Now I would like to make the water plate displayed and then hide all the child components of the water plate before the export continues.

Thanks
JS

Wouldn't the water plate be a component in the assembly with its own individual drawing? If so, the existing code should find and export that drawing.

But, since you are here asking the question, I'm guessing that you do not have it set up this way... Can you elaborate on your assembly structure?

Thank you for the help.

Yes you are correct the water plate is a component of an assembly and it also has child components. the water plate has its own individual drawing that shows when you make it displayed and enter drafting.

Below is an example of our structure that I am trying to describe.

Top Level Assy
--Core Plate 1-
----Water plate 1-
------O ring -
------Bolt -
------Pipe plug -
----Water plate 2-
------O ring -
------Bolt -
------Pipe plug -
----Insert 1
------Bolt -

The goal would be to step through the Top level assembly making each component displayed so Core plate 1 would be displayed and Water Plate 1, Water Plate 2, Insert 1 hidden. Then the views updated and exported. Then Water Plate 1 would be displayed and o ring, bolt, pipe plug hidden views updated PDF exported and then move back down the assembly.