Code:
Option Strict Off
Imports System
Imports System.Windows.Forms
Imports NXOpen
Module Main
Dim theSession As Session = Session.GetSession()
Dim theUFSession As NXOpen.UF.UFSession = NXOpen.UF.UFSession.GetUFSession()
Dim cFunc1, cFunc2, cFunc3 As Integer
Public Class Form1
Inherits System.Windows.Forms.Form
Public Shared Sub Main()
Dim fMainForm As Form1 = Nothing
If theSession.ActiveSketch Is Nothing Then
MessageBox.Show("A sketch must be active in order to run this journal")
Exit Sub
End If
'Dim fMainForm As New Form1
fMainForm = New Form1
fMainForm.ShowDialog()
fMainForm.Dispose()
End Sub
Public Sub New()
MyBase.New()
Me.InitializeComponent()
End Sub
#Region " Windows Forms Designer generated code "
Friend WithEvents Button_Calculate As System.Windows.Forms.Button
Friend WithEvents TextBox_X As System.Windows.Forms.TextBox
Friend WithEvents Label_X As System.Windows.Forms.Label
Friend WithEvents TextBox_Grouting As System.Windows.Forms.TextBox
Friend WithEvents Label_Grouting As System.Windows.Forms.Label
Friend WithEvents TextBox_Tolerance As System.Windows.Forms.TextBox
Friend WithEvents Label_Tolerance As System.Windows.Forms.Label
Friend WithEvents TextBox_Width As System.Windows.Forms.TextBox
Friend WithEvents TextBox_Height As System.Windows.Forms.TextBox
Friend WithEvents Label_Calculation As System.Windows.Forms.Label
Friend WithEvents Label_Spec As System.Windows.Forms.Label
Friend WithEvents Label_Design As System.Windows.Forms.Label
Friend WithEvents ListBox_Design As System.Windows.Forms.ListBox
Friend WithEvents Label_Width As System.Windows.Forms.Label
Friend WithEvents Label_Height As System.Windows.Forms.Label
Friend WithEvents TextBox_Weight As System.Windows.Forms.TextBox
Friend WithEvents Label_Weight As System.Windows.Forms.Label
Friend WithEvents Button_Create As System.Windows.Forms.Button
Private Sub InitializeComponent()
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(Form1))
Me.Button_Calculate = New System.Windows.Forms.Button
Me.TextBox_X = New System.Windows.Forms.TextBox
Me.Label_X = New System.Windows.Forms.Label
Me.TextBox_Grouting = New System.Windows.Forms.TextBox
Me.Label_Grouting = New System.Windows.Forms.Label
Me.TextBox_Tolerance = New System.Windows.Forms.TextBox
Me.Label_Tolerance = New System.Windows.Forms.Label
Me.TextBox_Width = New System.Windows.Forms.TextBox
Me.TextBox_Height = New System.Windows.Forms.TextBox
Me.Label_Calculation = New System.Windows.Forms.Label
Me.Label_Spec = New System.Windows.Forms.Label
Me.Label_Design = New System.Windows.Forms.Label
Me.ListBox_Design = New System.Windows.Forms.ListBox
Me.Label_Width = New System.Windows.Forms.Label
Me.Label_Height = New System.Windows.Forms.Label
Me.TextBox_Weight = New System.Windows.Forms.TextBox
Me.Label_Weight = New System.Windows.Forms.Label
Me.Button_Create = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'Button_Calculate
'
Me.Button_Calculate.Location = New System.Drawing.Point(38, 465)
Me.Button_Calculate.Name = "Button_Calculate"
Me.Button_Calculate.Size = New System.Drawing.Size(124, 33)
Me.Button_Calculate.TabIndex = 0
Me.Button_Calculate.Text = "Calculate"
'Me.Button_Calculate.UseVisualStyleBackColor = True
'
'TextBox_X
'
Me.TextBox_X.Location = New System.Drawing.Point(133, 159)
Me.TextBox_X.Name = "TextBox_X"
Me.TextBox_X.Size = New System.Drawing.Size(53, 20)
Me.TextBox_X.TabIndex = 1
'
'Label_X
'
Me.Label_X.AutoSize = True
Me.Label_X.Location = New System.Drawing.Point(15, 162)
Me.Label_X.Name = "Label_X"
Me.Label_X.Size = New System.Drawing.Size(39, 13)
Me.Label_X.TabIndex = 2
Me.Label_X.Text = "X [mm]"
'
'TextBox_Grouting
'
Me.TextBox_Grouting.Location = New System.Drawing.Point(133, 185)
Me.TextBox_Grouting.Name = "TextBox_Grouting"
Me.TextBox_Grouting.Size = New System.Drawing.Size(53, 20)
Me.TextBox_Grouting.TabIndex = 3
'
'Label_Grouting
'
Me.Label_Grouting.AutoSize = True
Me.Label_Grouting.Location = New System.Drawing.Point(13, 189)
Me.Label_Grouting.Name = "Label_Grouting"
Me.Label_Grouting.Size = New System.Drawing.Size(64, 13)
Me.Label_Grouting.TabIndex = 8
Me.Label_Grouting.Text = "Grouting [%]"
'
'TextBox_Tolerance
'
Me.TextBox_Tolerance.Location = New System.Drawing.Point(133, 211)
Me.TextBox_Tolerance.Name = "TextBox_Tolerance"
Me.TextBox_Tolerance.Size = New System.Drawing.Size(53, 20)
Me.TextBox_Tolerance.TabIndex = 9
'
'Label_Tolerance
'
Me.Label_Tolerance.AutoSize = True
Me.Label_Tolerance.Location = New System.Drawing.Point(13, 215)
Me.Label_Tolerance.Name = "Label_Tolerance"
Me.Label_Tolerance.Size = New System.Drawing.Size(80, 13)
Me.Label_Tolerance.TabIndex = 10
Me.Label_Tolerance.Text = "Tolerance [mm]"
'
'TextBox_Width
'
Me.TextBox_Width.Location = New System.Drawing.Point(133, 347)
Me.TextBox_Width.Name = "TextBox_Width"
Me.TextBox_Width.ReadOnly = True
Me.TextBox_Width.Size = New System.Drawing.Size(63, 20)
Me.TextBox_Width.TabIndex = 11
'
'TextBox_Height
'
Me.TextBox_Height.Location = New System.Drawing.Point(133, 374)
Me.TextBox_Height.Name = "TextBox_Height"
Me.TextBox_Height.ReadOnly = True
Me.TextBox_Height.Size = New System.Drawing.Size(63, 20)
Me.TextBox_Height.TabIndex = 12
'
'Label_Calculation
'
Me.Label_Calculation.AutoSize = True
Me.Label_Calculation.Location = New System.Drawing.Point(130, 317)
Me.Label_Calculation.Name = "Label_Calculation"
Me.Label_Calculation.Size = New System.Drawing.Size(59, 13)
Me.Label_Calculation.TabIndex = 13
Me.Label_Calculation.Text = "Calculation"
'
'Label_Spec
'
Me.Label_Spec.AutoSize = True
Me.Label_Spec.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!)
Me.Label_Spec.Location = New System.Drawing.Point(130, 128)
Me.Label_Spec.Name = "Label_Spec"
Me.Label_Spec.Size = New System.Drawing.Size(110, 13)
Me.Label_Spec.TabIndex = 14
Me.Label_Spec.Text = "Gasket Specifications"
'
'Label_Design
'
Me.Label_Design.AutoSize = True
Me.Label_Design.Location = New System.Drawing.Point(13, 250)
Me.Label_Design.Name = "Label_Design"
Me.Label_Design.Size = New System.Drawing.Size(77, 13)
Me.Label_Design.TabIndex = 15
Me.Label_Design.Text = "Gasket Design"
'
'ListBox_Design
'
'Me.ListBox_Design.FormattingEnabled = True
Me.ListBox_Design.Items.AddRange(New Object() {"Nr. 1", "Nr. 2"})
Me.ListBox_Design.Location = New System.Drawing.Point(133, 241)
Me.ListBox_Design.Name = "ListBox_Design"
Me.ListBox_Design.Size = New System.Drawing.Size(53, 30)
Me.ListBox_Design.TabIndex = 16
'
'Label_Width
'
Me.Label_Width.AutoSize = True
Me.Label_Width.Location = New System.Drawing.Point(13, 347)
Me.Label_Width.Name = "Label_Width"
Me.Label_Width.Size = New System.Drawing.Size(60, 13)
Me.Label_Width.TabIndex = 17
Me.Label_Width.Text = "Width [mm]"
'
'Label_Height
'
Me.Label_Height.AutoSize = True
Me.Label_Height.Location = New System.Drawing.Point(13, 374)
Me.Label_Height.Name = "Label_Height"
Me.Label_Height.Size = New System.Drawing.Size(63, 13)
Me.Label_Height.TabIndex = 18
Me.Label_Height.Text = "Height [mm]"
'
'TextBox_Weight
'
Me.TextBox_Weight.Location = New System.Drawing.Point(133, 400)
Me.TextBox_Weight.Name = "TextBox_Weight"
Me.TextBox_Weight.ReadOnly = True
Me.TextBox_Weight.Size = New System.Drawing.Size(63, 20)
Me.TextBox_Weight.TabIndex = 19
'
'Label_Weight
'
Me.Label_Weight.AutoSize = True
Me.Label_Weight.Location = New System.Drawing.Point(13, 400)
Me.Label_Weight.Name = "Label_Weight"
Me.Label_Weight.Size = New System.Drawing.Size(105, 13)
Me.Label_Weight.TabIndex = 20
Me.Label_Weight.Text = "Weight per 10mm [g]"
'
'Button_Create
'
Me.Button_Create.Location = New System.Drawing.Point(38, 515)
Me.Button_Create.Name = "Button_Create"
Me.Button_Create.Size = New System.Drawing.Size(124, 33)
Me.Button_Create.TabIndex = 21
Me.Button_Create.Text = "Create Geometry"
'Me.Button_Create.UseVisualStyleBackColor = True
'
'
'Form1
'
'Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
'Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(409, 577)
Me.Controls.Add(Me.Button_Create)
Me.Controls.Add(Me.Label_Weight)
Me.Controls.Add(Me.TextBox_Weight)
Me.Controls.Add(Me.Label_Height)
Me.Controls.Add(Me.Label_Width)
Me.Controls.Add(Me.ListBox_Design)
Me.Controls.Add(Me.Label_Design)
Me.Controls.Add(Me.Label_Spec)
Me.Controls.Add(Me.Label_Calculation)
Me.Controls.Add(Me.TextBox_Height)
Me.Controls.Add(Me.TextBox_Width)
Me.Controls.Add(Me.Label_Tolerance)
Me.Controls.Add(Me.TextBox_Tolerance)
Me.Controls.Add(Me.Label_Grouting)
Me.Controls.Add(Me.TextBox_Grouting)
Me.Controls.Add(Me.Label_X)
Me.Controls.Add(Me.TextBox_X)
Me.Controls.Add(Me.Button_Calculate)
Me.Name = "Gasket Shape"
Me.Text = "Gasket Shape"
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
#End Region
Private Sub ButtonCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_Calculate.Click
Dim cError As Integer
If TextBox_X.Text = "" Or TextBox_Grouting.Text = "" Or TextBox_Tolerance.Text = "" Or ListBox_Design.Text = "" Then
cError = 1
MsgBox("Please fill in all text fields.", MsgBoxStyle.Critical, "Error")
End If
If cError = 0 Then
TextBox_Height.Text = 10
TextBox_Width.Text = 11
TextBox_Weight.Text = 13
End If
'Me.Dispose()
End Sub
Private Sub ButtonCreate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_Create.Click
Dim cError As Integer
If TextBox_X.Text = "" Or TextBox_Grouting.Text = "" Or TextBox_Tolerance.Text = "" Or ListBox_Design.Text = "" Then
cError = 1
MsgBox("Please fill in all text fields.", MsgBoxStyle.Critical, "Error")
Else
CreateShape(TextBox_X.Text, TextBox_Grouting.Text, TextBox_Tolerance.Text, ListBox_Design.Text)
Me.Close()
End If
End Sub
Public Function CreateShape(ByVal cFunc1 As Integer, ByVal cFunc2 As Integer, ByVal cFunc3 As Integer, ByVal cFunc4 As String)
' .... hier steht die Anweisung um die Geometrie zu erstellen
End Function
End Class
End Module