Code:
Option Strict Off
Imports System
Imports System.IO
Imports System.Collections.Generic
Imports System.Math
Imports System.Windows.Forms
Imports NXOpen
Imports NXOpenUI
Imports NXOpen.UF
Imports NXOpen.Selection
Imports NXOpen.Assemblies
Imports NXOpen.Drawings
Module Module1
Dim theSession As Session = Session.GetSession()
Public workPart As Part = theSession.Parts.Work
Sub Main()
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "journal")
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
'-----------------------------------------------------------------------
Dim theSession As Session = Session.GetSession()
Public id1 As Session.UndoMarkId
Public nErrs1 As Integer
Private point1_y_koo As Expression = CType(workPart.Expressions.FindObject("point1_y"), Expression)
Private point2_y_koo As String
'-----------------------------------------------------------------------
Private Sub Close_Button_Click(sender As Object, e As EventArgs) Handles Close_Button.Click
Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
Me.Close()
End Sub
'-----------------------------------------------------------------------
Private Sub Create_update_expr_Button_Click(sender As Object, e As EventArgs) Handles Create_update_expr_Button.Click
Dim unit_mm As Unit = CType(workPart.UnitCollection.FindObject("MilliMeter"), Unit)
point2_y_koo = point1_y_koo.value - 32.5
Dim expression1 As Expression
expression1 = workPart.Expressions.CreateWithUnits("point2_y=" & point2_y_koo, unit_mm)
nErrs1 = theSession.UpdateManager.DoUpdate(id1)
End Sub
'-----------------------------------------------------------------------
End Class
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Dialog1
Inherits System.Windows.Forms.Form
'Das Formular überschreibt den Löschvorgang, um die Komponentenliste zu bereinigen.
<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
'Wird vom Windows Form-Designer benötigt.
Private components As System.ComponentModel.IContainer
'Hinweis: Die folgende Prozedur ist für den Windows Form-Designer erforderlich.
'Das Bearbeiten ist mit dem Windows Form-Designer möglich.
'Das Bearbeiten mit dem Code-Editor ist nicht möglich.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.create_update_expr_button = New System.Windows.Forms.Button()
Me.close_button = New System.Windows.Forms.Button()
Me.SuspendLayout()
'
'create_update_expr_button
'
Me.create_update_expr_button.Location = New System.Drawing.Point(93, 227)
Me.create_update_expr_button.Name = "create_update_expr_button"
Me.create_update_expr_button.Size = New System.Drawing.Size(179, 23)
Me.create_update_expr_button.TabIndex = 0
Me.create_update_expr_button.Text = "Create/Update Expressions"
Me.create_update_expr_button.UseVisualStyleBackColor = True
'
'close_button
'
Me.close_button.Location = New System.Drawing.Point(12, 227)
Me.close_button.Name = "close_button"
Me.close_button.Size = New System.Drawing.Size(75, 23)
Me.close_button.TabIndex = 1
Me.close_button.Text = "Close"
Me.close_button.UseVisualStyleBackColor = True
'
'Dialog1
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(284, 262)
Me.Controls.Add(Me.close_button)
Me.Controls.Add(Me.create_update_expr_button)
Me.Name = "Dialog1"
Me.Text = "Dialog1"
Me.ResumeLayout(False)
End Sub
Friend WithEvents create_update_expr_button As System.Windows.Forms.Button
Friend WithEvents close_button As System.Windows.Forms.Button
End Class