Imports System Imports System.IO Imports System.Collections.Generic Imports System.Windows.Forms Imports NXOpen Imports NXOpen.UF Imports NXOpen.Utilities Imports NXOpen.Selection Imports NXOpen.Drawings Imports NXOpen.Assemblies Public Class Farbe Inherits System.Windows.Forms.Form Dim sess As Session = Session.GetSession Dim ufs As UFSession = UFSession.GetUFSession Dim ui As UI = UI.GetUI Dim lw As ListingWindow = sess.ListingWindow Dim undomark As Session.UndoMarkId Dim wp As Part = sess.Parts.Work Dim sm As Selection = ui.GetUI.SelectionManager Friend WithEvents Label2 As System.Windows.Forms.Label Dim selectedComps(-1) As Component Public Shared Sub Main() Application.Run(New Farbe) End Sub Private Sub New() MyBase.new() Me.InitializeComponent() End Sub Private Sub btn_exit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_exit.Click Me.Close() End Sub Public Function SelectComponents(ByRef comps() As NXObject) As Integer ui.LockAccess() Dim mask(0) As Selection.MaskTriple mask(0) = New Selection.MaskTriple(UFConstants.UF_component_type, 0, 0) Dim sel1 As Selection.Response Do sel1 = ui.SelectionManager.SelectObjects("Select Components", _ "Select Components", Selection.SelectionScope.AnyInAssembly, Selection.SelectionAction.ClearAndEnableSpecific, _ False, False, mask, comps) Loop While sel1 = Selection.Response.ObjectSelected Or _ sel1 = Selection.Response.ObjectSelectedByName ui.UnlockAccess() Return comps.GetLength(0) End Function #Region "VS Designer Code" 'Das Formular überschreibt den Löschvorgang, um die Komponentenliste zu bereinigen. _ 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 Friend WithEvents btn_exit As System.Windows.Forms.Button Friend WithEvents kompselect As System.Windows.Forms.Button Friend WithEvents RadioButton1 As System.Windows.Forms.RadioButton Friend WithEvents RadioButton2 As System.Windows.Forms.RadioButton Friend WithEvents RadioButton3 As System.Windows.Forms.RadioButton Friend WithEvents Label1 As System.Windows.Forms.Label '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. _ Private Sub InitializeComponent() Me.btn_exit = New System.Windows.Forms.Button Me.kompselect = New System.Windows.Forms.Button Me.RadioButton1 = New System.Windows.Forms.RadioButton Me.RadioButton2 = New System.Windows.Forms.RadioButton Me.RadioButton3 = New System.Windows.Forms.RadioButton Me.Label1 = New System.Windows.Forms.Label Me.Label2 = New System.Windows.Forms.Label Me.SuspendLayout() ' 'btn_exit ' Me.btn_exit.Location = New System.Drawing.Point(253, 184) Me.btn_exit.Margin = New System.Windows.Forms.Padding(4) Me.btn_exit.Name = "btn_exit" Me.btn_exit.Size = New System.Drawing.Size(111, 28) Me.btn_exit.TabIndex = 0 Me.btn_exit.Text = "Beenden" Me.btn_exit.UseVisualStyleBackColor = True ' 'kompselect ' Me.kompselect.Location = New System.Drawing.Point(215, 103) Me.kompselect.Margin = New System.Windows.Forms.Padding(4) Me.kompselect.Name = "kompselect" Me.kompselect.Size = New System.Drawing.Size(187, 28) Me.kompselect.TabIndex = 16 Me.kompselect.Text = "Teil auswählen" Me.kompselect.UseVisualStyleBackColor = True ' 'RadioButton1 ' Me.RadioButton1.AutoSize = True Me.RadioButton1.Checked = True Me.RadioButton1.Location = New System.Drawing.Point(73, 82) Me.RadioButton1.Name = "RadioButton1" Me.RadioButton1.Size = New System.Drawing.Size(56, 21) Me.RadioButton1.TabIndex = 17 Me.RadioButton1.TabStop = True Me.RadioButton1.Text = "Gehäuse" Me.RadioButton1.UseVisualStyleBackColor = True ' 'RadioButton2 ' Me.RadioButton2.AutoSize = True Me.RadioButton2.Location = New System.Drawing.Point(73, 124) Me.RadioButton2.Name = "RadioButton2" Me.RadioButton2.Size = New System.Drawing.Size(66, 21) Me.RadioButton2.TabIndex = 18 Me.RadioButton2.Text = "Lichtquelle" Me.RadioButton2.UseVisualStyleBackColor = True ' 'RadioButton3 ' Me.RadioButton3.AutoSize = True Me.RadioButton3.Location = New System.Drawing.Point(73, 104) Me.RadioButton3.Name = "RadioButton3" Me.RadioButton3.Size = New System.Drawing.Size(66, 21) Me.RadioButton3.TabIndex = 18 Me.RadioButton3.Text = "Reflektor" Me.RadioButton3.UseVisualStyleBackColor = True ' 'Label1 ' Me.Label1.AutoSize = True Me.Label1.Location = New System.Drawing.Point(40, 52) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(108, 17) Me.Label1.TabIndex = 19 Me.Label1.Text = "Kategorie auswählen" ' 'Label2 ' Me.Label2.AutoSize = True Me.Label2.Location = New System.Drawing.Point(266, 84) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(67, 17) Me.Label2.TabIndex = 20 Me.Label2.Text = "anklicken" ' 'Kategorisierung (Hauptfenster) ' Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None Me.BackColor = System.Drawing.SystemColors.Control Me.ClientSize = New System.Drawing.Size(415, 228) Me.Controls.Add(Me.Label2) Me.Controls.Add(Me.Label1) Me.Controls.Add(Me.RadioButton3) Me.Controls.Add(Me.RadioButton2) Me.Controls.Add(Me.RadioButton1) Me.Controls.Add(Me.kompselect) Me.Controls.Add(Me.btn_exit) Me.Margin = New System.Windows.Forms.Padding(4) Me.Name = "Kategorisierung" Me.Text = "Optische Kategorisierung" Me.TopMost = True Me.ResumeLayout(False) Me.PerformLayout() End Sub #End Region Private Sub ListBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) End Sub Private Sub kompselect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kompselect.Click Try Me.Visible = False Dim mess As String = "Select single Object" Dim title As String = "Selection with SelectionType" Dim scope As SelectionScope = SelectionScope.AnyInAssembly Dim keep_hl As Boolean = False Dim type_arr() As SelectionType = {SelectionType.Faces} Dim obj As NXObject = Nothing Dim cursor As Point3d Dim sel_resp As Response sel_resp = sm.SelectObject(mess, title, scope, keep_hl, type_arr, obj, cursor) If sel_resp < 4 Then Exit Sub Dim objs As NXObject() = {obj} obj_info(objs) Catch ex As Exception End Try Me.Close() End Sub Private Sub obj_info(ByVal obj() As NXObject) 'sess.Information.DisplayObjectsDetails(obj) Try Dim Kategorie As Integer = Nothing Select Case True Case RadioButton1.Checked Kategorie = 10 Case RadioButton2.Checked Kategorie = 20 Case RadioButton3.Checked Kategorie = 30 Case Else End Select MsgBox(Kategorie) 'CType(obj, DisplayableObject).Layer = 10 Catch ex As Exception End Try End Sub End Class Module unload Public Function GetUnloadOption(ByVal dummy As String) As Integer Return Session.LibraryUnloadOption.Immediately End Function End Module