Submitted by nitem_Arda on Mon, 12/04/2017 - 04:30
Forums:
hello,
Can we print the data we want to display in the journal window or in the listing window on the letterhead paper?
Example: Can we print this dataset on the datum drawing in the B13 zone field in the cell we want in the tabular note?
re: add text to a tabular note
The code below shows how to add text to an existing tabular note. It will add the work part name to the first tabular note that it finds. Start a new, blank part, create a tabular note, and run the journal.
Option Strict Off
Imports System
Imports System.Collections.Generic
Imports NXOpen
Imports NXOpen.UF
Module Module1
Dim theSession As Session = Session.GetSession()
Dim theUfSession As UFSession = UFSession.GetUFSession()
Dim workPart As Part = theSession.Parts.Work
Dim lw As ListingWindow = theSession.ListingWindow
Sub Main()
If IsNothing(theSession.Parts.Work) Then
'active part required
Return
End If
Dim lw As ListingWindow = theSession.ListingWindow
lw.Open()
Const undoMarkName As String = "NXJ tabular note add text"
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, undoMarkName)
Dim myTabularNoteTags As New List(Of Tag)
If FindTabularNotes(myTabularNoteTags) = 0 Then
'no tabular notes to process
Return
End If
Dim numRows As Integer
theUfSession.Tabnot.AskNmRows(myTabularNoteTags.Item(0), numRows)
Dim numCols As Integer
theUfSession.Tabnot.AskNmColumns(myTabularNoteTags.Item(0), numCols)
Dim tableOrigin(2) As Double
Dim tableSectionTag As Tag
theUfSession.Tabnot.AskNthSection(myTabularNoteTags.Item(0), 0, tableSectionTag)
Dim rowTag As Tag
theUfSession.Tabnot.AskNthRow(myTabularNoteTags.Item(0), 0, rowTag)
Dim colTag As Tag
theUfSession.Tabnot.AskNthColumn(myTabularNoteTags.Item(0), 0, colTag)
Dim cellTag As Tag
theUfSession.Tabnot.AskCellAtRowCol(rowTag, colTag, cellTag)
theUfSession.Tabnot.SetCellText(cellTag, workPart.Leaf)
lw.Close()
End Sub
Function FindTabularNotes(ByRef theTabNotes As List(Of Tag)) As Integer
Dim tmpTabNote As NXOpen.Tag = NXOpen.Tag.Null
Dim type As Integer
Dim subtype As Integer
Do
theUfSession.Obj.CycleObjsInPart(workPart.Tag, UFConstants.UF_tabular_note_type, tmpTabNote)
If tmpTabNote = NXOpen.Tag.Null Then
Continue Do
End If
If tmpTabNote <> NXOpen.Tag.Null Then
theUfSession.Obj.AskTypeAndSubtype(tmpTabNote, type, subtype)
If subtype = UFConstants.UF_tabular_note_subtype Then
theTabNotes.Add(tmpTabNote)
End If
End If
Loop Until tmpTabNote = NXOpen.Tag.Null
Return theTabNotes.Count
End Function
Public Function GetUnloadOption(ByVal dummy As String) As Integer
'Unloads the image immediately after execution within NX
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
End Function
End Module
tabular note
hello,
is this journal using NX 8.0? I could not run it.
re: NX 8 error
The code was written and tested on NX 9. I don't see any commands in there that would prevent it running on NX 8; did you get an error message?
Journaling / NXOpen API
Hello there,
macro is running but it does not give an error and it does not understand what it is doing. It looks like it's running idle.
re: run journal
Start a new, blank part, switch to drafting, and create a new tabular note before running the journal. It should write the part name into the tabular note. If it does not find a tabular note to work with, it will do nothing.