' Michael Knaupp Fa. Kramksi ' Programm ' Datum: ' Änderung:---- ' Option Strict Off Imports System Imports System.Collections Imports System.IO Imports System.Environment Imports System.Windows.Forms Imports NXOpen Imports NXOpen.UF Imports NXOpen.UI Imports NXOpen.Utilities Imports NXOpen.Assemblies Module My_Programm Sub Main Dim s As Session = Session.GetSession() Dim ufs As UFSession = UFSession.GetUFSession() Dim lw As ListingWindow = s.ListingWindow Dim wP As Part = s.Parts.Work Dim dp As Part = s.Parts.Display 'NX Manager Aktiv? Dim managerActive As Boolean ufs.UF.IsUgmanagerActive(managerActive) If managerActive = True Then Windows.Forms.MessageBox.Show("Diese Programm arbeitet nur Nativ / This programm is not for Teamcenter Env") Exit Sub End If ' Ein Teil geladen? if s.Parts.Work is Nothing Then Windows.Forms.MessageBox.Show("Kein Teil geladen! - No Part Loaded!") Exit Sub End If 'modulabfrage Dim module_id As Integer = 0 ufs.UF.AskApplicationModule(module_id) If module_id = UFConstants.UF_APP_DRAFTING Then Windows.Forms.MessageBox.Show("Bitte ins Modeling wechseln / Please change to modeling") Exit Sub End If ' Undo Mark setzten s.SetUndoMark( Session.MarkVisibility.Visible, "undo_mark") ' Msg Box MsgBox("STRING", MsgBoxStyle.Exclamation) Windows.Forms.MessageBox.Show("String....") ' Listing Window NX lw.Open() lw.WriteLine("STRING") ' Ansicht wP.ModelingViews.WorkView.Regenerate() ufs.Disp.RegenerateDisplay wP.Views.WorkView.Fit() 'Schleifen Dim i As Integer = 1 Do While i <= 5 i += 1 Loop Dim f As Integer = 1 Dim arr() As Integer = {12, 7, 4} For Each f In arr lw.WriteLine(f) Next ' Catch Try ... Catch ex As Exception 'lw.WriteLine("Exp - Name:" + ex.GetType.Name) 'lw.WriteLine("Fehlertext:" + ex.Message) 'lw.WriteLine("Fehlerort: " + ex.StackTrace) End Try End Sub ' Unload options Public Function GetUnloadOption(ByVal dummy As String) As Integer 'Unloads the image immediately after execution within NX GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately '----Other unload options------- 'Unloads the image when the NX session terminates 'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination 'Unloads the image explicitly, via an unload dialog 'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Explicitly '------------------------------- End Function ' Name aus Angabe mit Pfad ziehen Public Function FileNameo(WithPath As String) Dim sWithoutPath As String Dim iLen As Integer Dim iWhere As Integer sWithoutPath = WithPath Do Until InStr(sWithoutPath, "\") = 0 iLen = Len(sWithoutPath) iWhere = InStr(sWithoutPath, "\") sWithoutPath = Right(sWithoutPath, iLen - iWhere) Loop FileNameo = sWithoutPath End Function End Module