Option Strict Off
Imports System
Imports System.IO
Imports System.Collections.Generic
Imports NXOpen
Imports NXOpen.Features
Imports NXOpenUI
Imports NXOpen.UF
Imports NXOpen.Utilities
Imports System.Math
Imports System.Windows.Forms
Imports System.Collections
Module Module1
Public ufs As UFSession = UFSession.GetUFSession()
Public theUI As UI = UI.GetUI
Public theSession As Session = Session.GetSession()
Public workPart As Part = theSession.Parts.Work
Public displayPart As Part = theSession.Parts.Display
Public lw As ListingWindow = theSession.ListingWindow
Public myBodies() As NXObject
Public myBody As NXOpen.Body
Sub Main()
Dim myDialog As New Form1
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
Function SBody(ByVal prompt As String, ByRef selObj As NXObject) As Selection.Response
'funkcja pobiera body wkazane przez użytkownika
Dim title As String = "Selection"
Dim includeFeatures As Boolean = False
Dim keepHighlighted As Boolean = False
Dim selAction As Selection.SelectionAction = Selection.SelectionAction.ClearAndEnableSpecific
Dim cursor As Point3d
Dim scope As Selection.SelectionScope = Selection.SelectionScope.WorkPart
Dim selectionMask_array(1) As Selection.MaskTriple
With selectionMask_array(0)
.Type = UFConstants.UF_component_type
.Subtype = UFConstants.UF_component_subtype
.SolidBodySubtype = 0
End With
With selectionMask_array(1)
.Type = UFConstants.UF_solid_type
.Subtype = 0
.SolidBodySubtype = UFConstants.UF_UI_SEL_FEATURE_BODY
End With
Dim resp As Selection.Response = theUI.SelectionManager.SelectTaggedObject(prompt, title, scope, selAction, _
includeFeatures, keepHighlighted, selectionMask_array, selObj, cursor)
If resp = Selection.Response.ObjectSelected OrElse _
resp = Selection.Response.ObjectSelectedByName Then
Return Selection.Response.Ok
Else
Return Selection.Response.Cancel
End If
End Function
Function Bodies(ByVal prompt As String, ByRef selObj() As NXObject) As Selection.Response
Dim theUI As UI = UI.GetUI
Dim title As String = "Selection"
Dim includeFeatures As Boolean = False
Dim keepHighlighted As Boolean = False
Dim selAction As Selection.SelectionAction = Selection.SelectionAction.ClearAndEnableSpecific
Dim scope As Selection.SelectionScope = Selection.SelectionScope.WorkPart
Dim selectionMask_array(1) As Selection.MaskTriple
With selectionMask_array(0)
.Type = UFConstants.UF_component_type
.Subtype = UFConstants.UF_component_subtype
.SolidBodySubtype = 0
End With
With selectionMask_array(1)
.Type = UFConstants.UF_solid_type
.Subtype = 0
.SolidBodySubtype = UFConstants.UF_UI_SEL_FEATURE_BODY
End With
Dim resp As Selection.Response = theUI.SelectionManager.SelectTaggedObjects(prompt, title, scope, selAction, includeFeatures, keepHighlighted, selectionMask_array, selObj)
If resp = Selection.Response.Ok Then
Return Selection.Response.Ok
Else
Return Selection.Response.Cancel
End If
End Function
End Module
Public Class Form1
Private Sub Button_OK_Click(sender As Object, e As EventArgs) Handles Button_OK.Click
Me.DialogResult = System.Windows.Forms.DialogResult.OK
Me.Close()
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button_Cancel.Click
Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
Me.Close()
End Sub
Private Sub SelectBodies_Click(sender As Object, e As EventArgs) Handles SelectBodies.Click
Me.Hide()
If Bodies("Wskaż zwierciadla", myBodies) = Selection.Response.Cancel Then
Exit Sub
End If
Me.Show()
End Sub
Private Sub SelectBody_Click(sender As Object, e As EventArgs) Handles SelectBody.Click
Me.Hide()
If SBody("Wskaż swiatłowód", myBody) = Selection.Response.Cancel Then
Exit Sub
End If
Me.Show()
End Sub
End Class
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form1
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.components = New System.ComponentModel.Container()
Me.Timer1 = New System.Windows.Forms.Timer(Me.components)
Me.Button_Cancel = New System.Windows.Forms.Button()
Me.Button_OK = New System.Windows.Forms.Button()
Me.SelectBody = New System.Windows.Forms.Button()
Me.SelectBodies = New System.Windows.Forms.Button()
Me.SuspendLayout()
'
'Button_Cancel
'
Me.Button_Cancel.Location = New System.Drawing.Point(25, 133)
Me.Button_Cancel.Name = "Button_Cancel"
Me.Button_Cancel.Size = New System.Drawing.Size(100, 42)
Me.Button_Cancel.TabIndex = 8
Me.Button_Cancel.Text = "Cancel"
Me.Button_Cancel.UseVisualStyleBackColor = True
'
'Button_OK
'
Me.Button_OK.Location = New System.Drawing.Point(193, 133)
Me.Button_OK.Name = "Button_OK"
Me.Button_OK.Size = New System.Drawing.Size(114, 42)
Me.Button_OK.TabIndex = 7
Me.Button_OK.Text = "OK"
Me.Button_OK.UseVisualStyleBackColor = True
'
'SelectBody
'
Me.SelectBody.Location = New System.Drawing.Point(25, 40)
Me.SelectBody.Name = "SelectBody"
Me.SelectBody.Size = New System.Drawing.Size(100, 45)
Me.SelectBody.TabIndex = 9
Me.SelectBody.Text = "Select Body"
Me.SelectBody.UseVisualStyleBackColor = True
'
'SelectBodies
'
Me.SelectBodies.Location = New System.Drawing.Point(193, 40)
Me.SelectBodies.Name = "SelectBodies"
Me.SelectBodies.Size = New System.Drawing.Size(114, 45)
Me.SelectBodies.TabIndex = 10
Me.SelectBodies.Text = "Select Bodies"
Me.SelectBodies.UseVisualStyleBackColor = True
'
'Form1
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(8.0!, 16.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(319, 192)
Me.Controls.Add(Me.SelectBodies)
Me.Controls.Add(Me.SelectBody)
Me.Controls.Add(Me.Button_OK)
Me.Controls.Add(Me.Button_Cancel)
Me.Name = "Form1"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "Add Attribute"
Me.ResumeLayout(False)
End Sub
Friend WithEvents Timer1 As System.Windows.Forms.Timer
Friend WithEvents Button_Cancel As System.Windows.Forms.Button
Friend WithEvents Button_OK As System.Windows.Forms.Button
Friend WithEvents SelectBody As System.Windows.Forms.Button
Friend WithEvents SelectBodies As System.Windows.Forms.Button
End Class