Robse
Industrial
- Jun 30, 2015
- 17
Hello, I am also courios about adding a new column to a parts list in NX. Has someone been succesful?
There was already a question in a thread before: "add a new column to partslist in NX 11 - using vb.net"
Could someone give me a tip how to define the columntype settings?
I found :
How do I forward all this information to my code?
Thank you and best regards
Hereby my first approach:
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Module Module1
Dim theSession As Session = Session.GetSession()
Dim theUfSession As UFSession = UFSession.GetUFSession()
Sub Main()
If IsNothing(theSession.Parts.BaseWork) Then
'active part required
Return
End If
Dim workPart As Part = theSession.Parts.Work
Const undoMarkName As String = "edit parts list column "
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, undoMarkName)
Dim partsListTags() As Tag
Dim numPartsLists As Integer
theUfSession.Plist.AskTags(partsListTags, numPartsLists)
If numPartsLists = 0 Then
Msgbox("No parts lists found in work part, exiting")
Return
End If
For Each temp As Tag In partsListTags
Dim colWidth As Double
colWidth = 10
Dim colPrefs As UFPlist.colPrefs = Nothing
theUfSession.Plist.AskDefaultColPrefs(colprefs)
Dim columntype As UFPlist.ColumnType = Nothing
'?? columntype = General
'?? How to define Attribute Name in example <W$=@$PART_NAME>
Dim columnTag As Tag = Tag.Null
theUfSession.Plist.CreateColumn(colWidth,colPrefs,columntype,columnTag)
theUfSession.Tabnot.AddColumn(temp, columnTag, UFConstants.UF_TABNOT_APPEND) 'UFConstants.UF_TABNOT_APPEND) '----- Adds at the top
Next
End Sub
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
There was already a question in a thread before: "add a new column to partslist in NX 11 - using vb.net"
Could someone give me a tip how to define the columntype settings?
I found :
How do I forward all this information to my code?
Thank you and best regards
Hereby my first approach:
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Module Module1
Dim theSession As Session = Session.GetSession()
Dim theUfSession As UFSession = UFSession.GetUFSession()
Sub Main()
If IsNothing(theSession.Parts.BaseWork) Then
'active part required
Return
End If
Dim workPart As Part = theSession.Parts.Work
Const undoMarkName As String = "edit parts list column "
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, undoMarkName)
Dim partsListTags() As Tag
Dim numPartsLists As Integer
theUfSession.Plist.AskTags(partsListTags, numPartsLists)
If numPartsLists = 0 Then
Msgbox("No parts lists found in work part, exiting")
Return
End If
For Each temp As Tag In partsListTags
Dim colWidth As Double
colWidth = 10
Dim colPrefs As UFPlist.colPrefs = Nothing
theUfSession.Plist.AskDefaultColPrefs(colprefs)
Dim columntype As UFPlist.ColumnType = Nothing
'?? columntype = General
'?? How to define Attribute Name in example <W$=@$PART_NAME>
Dim columnTag As Tag = Tag.Null
theUfSession.Plist.CreateColumn(colWidth,colPrefs,columntype,columnTag)
theUfSession.Tabnot.AddColumn(temp, columnTag, UFConstants.UF_TABNOT_APPEND) 'UFConstants.UF_TABNOT_APPEND) '----- Adds at the top
Next
End Sub
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