Adding or editing a number of attributes to a component

I found this journal, that cowski created, on eng-tips. Is it possible to modify this so the dialog box will list ALL the attributes I would like to add or edit to a component? I am new to journaling.

Option Strict Off
Imports System
Imports NXOpen
Imports System.Windows.Forms

Module Module1

Dim theSession As Session = Session.GetSession()
Public workPart As Part = theSession.Parts.Work

Sub Main()

Dim myDialog As New Dialog1
myDialog.ShowDialog()

End Sub

Public Function GetUnloadOption(ByVal dummy As String) As Integer

'Unloads the image when the NX session terminates
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination

End Function

End Module

Public Class Dialog1
Private myAttributeTitle As String = "DET #"
Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
Me.DialogResult = System.Windows.Forms.DialogResult.OK

workPart.SetAttribute(myAttributeTitle, TextBox1.Text)

Me.Close()
End Sub

Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
Me.Close()
End Sub

Private Sub Dialog1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

Try
TextBox1.Text = workPart.GetStringAttribute(myAttributeTitle)
Catch ex As ApplicationException
'attribute does not exist
TextBox1.Text = ""
End Try

Label1.Text = myAttributeTitle

End Sub
End Class

_
Partial Class Dialog1
Inherits System.Windows.Forms.Form

'Form overrides dispose to clean up the component list.
_
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
_
Private Sub InitializeComponent()
Me.TableLayoutPanel1 = New System.Windows.Forms.TableLayoutPanel()
Me.OK_Button = New System.Windows.Forms.Button()
Me.Cancel_Button = New System.Windows.Forms.Button()
Me.Label1 = New System.Windows.Forms.Label()
Me.TextBox1 = New System.Windows.Forms.TextBox()
Me.TableLayoutPanel1.SuspendLayout()
Me.SuspendLayout()
'
'TableLayoutPanel1
'
Me.TableLayoutPanel1.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.TableLayoutPanel1.ColumnCount = 2
Me.TableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50.0!))
Me.TableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50.0!))
Me.TableLayoutPanel1.Controls.Add(Me.OK_Button, 0, 0)
Me.TableLayoutPanel1.Controls.Add(Me.Cancel_Button, 1, 0)
Me.TableLayoutPanel1.Location = New System.Drawing.Point(277, 122)
Me.TableLayoutPanel1.Name = "TableLayoutPanel1"
Me.TableLayoutPanel1.RowCount = 1
Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50.0!))
Me.TableLayoutPanel1.Size = New System.Drawing.Size(146, 29)
Me.TableLayoutPanel1.TabIndex = 0
'
'OK_Button
'
Me.OK_Button.Anchor = System.Windows.Forms.AnchorStyles.None
Me.OK_Button.Location = New System.Drawing.Point(3, 3)
Me.OK_Button.Name = "OK_Button"
Me.OK_Button.Size = New System.Drawing.Size(67, 23)
Me.OK_Button.TabIndex = 0
Me.OK_Button.Text = "OK"
'
'Cancel_Button
'
Me.Cancel_Button.Anchor = System.Windows.Forms.AnchorStyles.None
Me.Cancel_Button.DialogResult = System.Windows.Forms.DialogResult.Cancel
Me.Cancel_Button.Location = New System.Drawing.Point(76, 3)
Me.Cancel_Button.Name = "Cancel_Button"
Me.Cancel_Button.Size = New System.Drawing.Size(67, 23)
Me.Cancel_Button.TabIndex = 1
Me.Cancel_Button.Text = "Cancel"
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(12, 52)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(134, 26)
Me.Label1.TabIndex = 1
Me.Label1.Text = "Attribute:"
Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(152, 56)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(234, 20)
Me.TextBox1.TabIndex = 2
'
'Dialog1
'
Me.AcceptButton = Me.OK_Button
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.CancelButton = Me.Cancel_Button
Me.ClientSize = New System.Drawing.Size(435, 163)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.TableLayoutPanel1)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "Dialog1"
Me.ShowInTaskbar = False
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent
Me.Text = "Dialog1"
Me.TableLayoutPanel1.ResumeLayout(False)
Me.ResumeLayout(False)
Me.PerformLayout()

End Sub
Friend WithEvents TableLayoutPanel1 As System.Windows.Forms.TableLayoutPanel
Friend WithEvents OK_Button As System.Windows.Forms.Button
Friend WithEvents Cancel_Button As System.Windows.Forms.Button
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox

End Class

What version of NX are you using? The attribute system got an overhaul in NX8 which will affect the code required for the journal.

I'm using NX8.0 right now...The journal I posted does work fine on NX8

Do you have a list of attributes that you want to edit/add?

If you don't have a copy of VB Express installed, I suggest you do so. It will make editing the form much easier (it also makes writing code much easier!).

What chnages I have to make to use this code to use in NX 7.5. And my attribute name is CALLOUT

Stay Hungry
Stay Foolish

The code posted (1st post) should work in NX 7.5.
Change the line:
Private myAttributeTitle As String = "DET #"
to:
Private myAttributeTitle As String = "CALLOUT"

@nxjournaling...Here is a list a commonly used attributes that I would like to be able to use this with.
DET #
DESCRIPTION
SIZE
CAT#
MATL_RC
VENDOR

Is VB Express you mentioned actually Visual Basic Express?. Is this something that I have to buy? If it makes writing code and designing forms easier than I'll will. Considering the fact that I am new to programming with journals or anything else for that matter, it will be worth it. Also I should mention this list of attribute is a work in process and may change per design project so modifying this journal on a job by job basis may be required. Thanks for you help

Visual Basic (VB for short) Express is a free pared down version of visual studio. It is a development environment that helps identify errors before you try to run the code. Also, as you work with objects, it presents a list of available properties and methods as you type which eliminates a lot of back and forth with the NXOpen help files. And if you plan on creating custom forms for user input/information, using an IDE is really the best way to go. You can find it at http://www.microsoft.com/visualstudio/eng/products/visual-studio-express...
(follow the products link). Looks like the 2012 version is available (I'm currently using the 2010 version), I think the version you want is "express for windows desktop" or the 2010 version "Visual Basic 2010 express".

HELP
I would like to use the following function

Public Function GetAttributeTitlesByType ( _
type As AttributeType _
) As AttributeInformation()

So I tried
Dim GetAttributeTitlesByType1() as NXObject.AttributeInformation
GetAttributeTitlesByType1 = mySelcomponent.GetAttributeTitlesByType(type(string))

but its giving me errors

any suggestions

Carlo Tony Daristotile

I think the error is coming in with the type that you are passing into the function. The function is expecting an integer value, you can use a value from an enumeration to get the type you want.


Dim GetAttributeTitlesByType1() as NXObject.AttributeInformation
GetAttributeTitlesByType1 = mySelcomponent.GetAttributeTitlesByType(NXObject.AttributeType.String)