×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Journal - Show Attribute Value on TextBox (User Form)
3

Journal - Show Attribute Value on TextBox (User Form)

Journal - Show Attribute Value on TextBox (User Form)

(OP)
Hello Eng-Tips, I have a question regarding Attributes and Journal (vb). I need a user form to request and add attributes to a component part and use those attributes on a title block. So far i have identified and know how to build a user form, request the attribute and store as a variable; my question is how to show the value from a existing attribute value on a textbox (user form) to let the designer change the value or not. Form "fill_in_title_block_templ.vb" example I could extract the UF code lines and add some other code lines (form others examples) to show the value as follow:

Dim strCompany As String = "Co.SA"
Me.Attr1.Text = thepart.GetStringAttribute(strCompany)

**These lines are "<System.Diagnostics.DebuggerStepThrough()>" block form fill_in_title_block_templ example

From the error message and the original code I could guess that there is an issue regarding local and global variables on the changes I just made.

NX 7.5.0.32, trying to learn Visual Basic 2010. Only 10 months of experience with NX and a couple of weeks with VB2010...newbie

RE: Journal - Show Attribute Value on TextBox (User Form)

3
Here's a very quick example:

CODE

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 = "Co.SA"  
    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  



<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _  
Partial Class Dialog1  
    Inherits System.Windows.Forms.Form  

 'Form overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()> _  
    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.
    <System.Diagnostics.DebuggerStepThrough()> _  
    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 

www.nxjournaling.com

RE: Journal - Show Attribute Value on TextBox (User Form)

(OP)
Thanks cowski for the your quick response. That's exactly what I looking for.thumbsup

Regards

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources