Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Batch export Assembly PDF Journal

Status
Not open for further replies.

NXGrunt

Mechanical
Oct 27, 2008
6
I've been using the batch export NX journal from the top of this thread for years thread561-377372
But it always had the issue of saving to MyDocs instead of the chosen folder and I never got around to fixing it. And the last post has a link to the fix but the link no longer works.

cowski said:
Thanks to Mike's log file, I was able to fix the issue where the files were being saved to MyDocs regardless of your chosen folder.

updated code

Any chance that anyone has the fix or an updated file? Its based on an older version of NXJ_PdfExporter and would be nice to update to the latest version too.

Using NX 10 from Teamcenter, and exporting outside TC if it matters.

Thanks!

 
Replies continue below

Recommended for you

Awesome! Thanks Cowski, it works great.

I was looking through the code to see if I could change the date format to DDMMMYY (ie 04JUN20)
I noticed this comment "'to do: internationalization for dates"

Any chance you have worked through this already or have any guidance for how to accomplish this?
 
Ok so that was easier to do than I thought, after some googling I added the 2 lines of code below 'Internationalization for dates and replaced "Today" with "strDate" in the line below that.
Code:
    Private _watermarkAddDatestamp As Boolean = True
    Public Property WatermarkAddDatestamp() As Boolean
        Get
            Return _watermarkAddDatestamp
        End Get
        Set(ByVal value As Boolean)
            lg.WriteLine("Set Property WatermarkAddDatestamp")
            _watermarkAddDatestamp = value
            lg.WriteLine("  watermarkAddDatestamp: " & _watermarkAddDatestamp.ToString)
            If _watermarkAddDatestamp Then
                'Internationalization for dates
		Dim regDate as Date = Date.Now()
		Dim strDate as String = regDate.ToString("ddMMMyyyy")
                _watermarkTextFinal = _watermarkText & " " & strDate
            Else
                _watermarkTextFinal = _watermarkText
            End If
            lg.WriteLine("  watermarkTextFinal: " & _watermarkTextFinal)
            lg.WriteLine("exiting Set Property WatermarkAddDatestamp")
            lg.WriteLine("")
        End Set
    End Property

See anything wrong with this code?
 
Excellent, Date is now working great, Thanks.

I am still having the same issue that the OP on the last thread had, on the first run not all PDF's are being generated. But they are then created on the second run.

It looks like it may have to do with the load state of the components. Any subcomponents that are only 'partially loaded' do not get exported. After running the journal, all components become 'fully loaded' and all are exported when run a second time.

From the log it looks like it is not seeing drawing sheets in any part files that are 'partially loaded'
Code:
Sub Commit
  number of drawing sheets in part file: 0
Function DeleteExistingPdfFile(C:\Test Prints\Subcomponent01_1.pdf)
  ** no drawing sheets in file: Subcomponent01
  exiting Sub ExportSheetsToPdf

Performing an 'Open Component Fully' command on all subcomponents before running the Journal also solves this. Is there a way to add this step to the code or is there another solution?

Thanks for all the help!

 
It looks like the LoadComponent subroutine below could be modified to also load partially loaded components, it already has a check to determine if the component is fully loaded. This is beyond my limited coding skills to do without completely breaking this.

Code:
Private Function LoadComponent(ByVal theComponent As Component) As Boolean

        lg.WriteLine("Sub LoadComponent()")

        Dim thePart As Part = theComponent.Prototype.OwningPart

        Dim partName As String = ""
        Dim refsetName As String = ""
        Dim instanceName As String = ""
        Dim origin(2) As Double
        Dim csysMatrix(8) As Double
        Dim transform(3, 3) As Double

        Try
            If thePart.IsFullyLoaded Then
                'component is fully loaded
            Else
                'component is partially loaded
            End If
            lg.WriteLine("  component: " & theComponent.DisplayName & " is already partially or fully loaded")
            lg.WriteLine("  return: True")
            lg.WriteLine("exiting Sub LoadComponent()")
            lg.WriteLine("")
            Return True
        Catch ex As NullReferenceException
            'component is not loaded
            Try
                lg.WriteLine("  component not loaded, retrieving part information")
                _theUfSession.Assem.AskComponentData(theComponent.Tag, partName, refsetName, instanceName, origin, csysMatrix, transform)
                lg.WriteLine("  component part file: " & partName)

                Dim theLoadStatus As PartLoadStatus
                _theSession.Parts.Open(partName, theLoadStatus)

                If theLoadStatus.NumberUnloadedParts > 0 Then
                    If theLoadStatus.NumberUnloadedParts > 1 Then
                        lg.WriteLine("  problem loading " & theLoadStatus.NumberUnloadedParts.ToString & " components")
                    Else
                        lg.WriteLine("  problem loading 1 component")
                    End If

                    Dim allReadOnly As Boolean = True
                    For i As Integer = 0 To theLoadStatus.NumberUnloadedParts - 1
                        lg.WriteLine("part name: " & theLoadStatus.GetPartName(i))
                        lg.WriteLine("part status: " & theLoadStatus.GetStatus(i))
                        If theLoadStatus.GetStatus(i) = 641058 Then
                            'read-only warning, file loaded ok
                        Else
                            '641044: file not found
                            allReadOnly = False
                            If Not _notLoaded.Contains(partName) Then
                                _notLoaded.Add(partName)
                            End If
                        End If
                        lg.WriteLine("status description: " & theLoadStatus.GetStatusDescription(i))
                        lg.WriteLine("")
                    Next
                    If allReadOnly Then
                        lg.WriteLine("  read-only warnings only")
                        lg.WriteLine("  return: True")
                        Return True
                    Else
                        'warnings other than read-only...
                        lg.WriteLine("  return: False")
                        lg.WriteLine("exiting Sub LoadComponent()")
                        lg.WriteLine("")
                        Return False
                    End If
                Else
                    lg.WriteLine("  component(s) loaded successfully")
                    lg.WriteLine("  return: True")
                    lg.WriteLine("exiting Sub LoadComponent()")
                    lg.WriteLine("")
                    Return True
                End If

            Catch ex2 As NXException
                lg.WriteLine("  Load error: " & ex2.Message)
                lg.WriteLine("  error code: " & ex2.ErrorCode)
                lg.WriteLine("  return: False")
                lg.WriteLine("exiting Sub LoadComponent()")
                lg.WriteLine("")
                If ex2.Message.ToLower = "file not found" Then
                    If Not _notLoaded.Contains(partName) Then
                        _notLoaded.Add(partName)
                    End If
                End If
                Return False
            End Try
        Catch ex As NXException
            lg.WriteLine("  Error in Sub LoadComponent: " & ex.Message)
            lg.WriteLine("  return: False")
            lg.WriteLine("exiting Sub LoadComponent()")
            lg.WriteLine("")
            Return False
        End Try

    End Function

End Class
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor