Sample NX Open .NET Visual Basic program : edit tabular note cell text
작성자k2ice작성시간08.06.30조회수709 목록 댓글 0Date: 23-MAY-2008
Subject: Sample NX Open .NET Visual Basic program : edit tabular note cell text
Note: GTAC provides programming examples for illustration only, and
assumes that you are familiar with the programming language being
demonstrated and the tools used to create and debug procedures. GTAC
support professionals can help explain the functionality of a particular
procedure, but we will not modify these examples to provide added
functionality or construct procedures to meet your specific needs.
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports System.Windows.Forms
Imports System.Environment
Module NXJournal
Dim nxopenSession As NXOpen.UF.UFSession
Sub Main
Dim tabular_note_section As NXOpen.Tag
Dim tabular_note As NXOpen.Tag
Dim row as NXOpen.Tag
Dim col as NXOpen.Tag
Dim cell as NXOpen.Tag
nxopenSession = NXOpen.UF.UFSession.GetUFSession()
While select_a_tabular_note(tabular_note_section) = Selection.Response.Ok
'MessageBox.Show("Tabular Note Section Tag:" & tabular_note_section.ToString())
' now get the tabular note tag from the section tag:
nxopenSession.Tabnot.AskTabularNoteOfSection( tabular_note_section, tabular_note )
'MessageBox.Show( "Tabular Note Section Tag:" & tabular_note_section.ToString() & _
' NewLine & "Tabular Note Object Tag:" & tabular_note.ToString() )
' turn off highlighting
nxopenSession.Disp.SetHighlight(tabular_note_section, 0)
nxopenSession.Tabnot.AskNthRow(tabular_note, 0, row)
nxopenSession.Tabnot.AskNthColumn(tabular_note, 0, col)
nxopenSession.Tabnot.AskCellAtRowCol(row, col, cell)
nxopenSession.Tabnot.SetCellText(cell, "Unrecyclable Styrofoam")
End While
End Sub
Function select_a_tabular_note(ByRef tabular_note As NXOpen.Tag) As Selection.Response
Dim message As String
Dim title As String = "Select a tabular note"
Dim scope As Integer = UFConstants.UF_UI_SEL_SCOPE_ANY_IN_ASSEMBLY
Dim response As Integer
Dim obj as NXOpen.Tag
Dim view As NXOpen.Tag
Dim cursor(2) As Double
Dim ip As UfUi.SelInitFnT = AddressOf init_proc
nxopenSession.Ui.LockUgAccess(UFConstants.UF_UI_FROM_CUSTOM)
Try
nxopenSession.Ui.SelectWithSingleDialog(message, title, scope, ip, Nothing, response, tabular_note, cursor, view)
Finally
nxopenSession.Ui.UnlockUgAccess(UFConstants.UF_UI_FROM_CUSTOM)
End Try
If response <> UFConstants.UF_UI_OBJECT_SELECTED Then
Return Selection.Response.Cancel
Else
Return Selection.Response.Ok
End If
End Function
Function init_proc(ByVal select_ As IntPtr, ByVal userdata As IntPtr) As Integer
' Selection initialization
Dim num_triples As Integer = 1
Dim mask_triples(0) As UFUi.Mask
mask_triples(0).object_type = UFConstants.UF_tabular_note_type
mask_triples(0).object_subtype = UFConstants.UF_tabular_note_section_subtype
mask_triples(0).solid_type = 0
nxopenSession.Ui.SetSelMask(select_, UfUi.SelMaskAction.SelMaskClearAndEnableSpecific, num_triples, mask_triples)
return UFConstants.UF_UI_SEL_SUCCESS
End Function
End Module