Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Add a new column to partslist in NX 11 - using vb.net (#2)

Status
Not open for further replies.

Robse

Industrial
Jun 30, 2015
17
0
0
CH
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
 
Replies continue below

Recommended for you

An error occurs when I try to set

columntype = UFPlist.ColumnType.ColumnTypeGeneral

This is the result: NXOpen.NXExepion:NXerrorstatus:3500024

Does anyone know what I am doing wrong?

Thank you and best regards
 
Status
Not open for further replies.
Back
Top