Hello,
I am new to this forum. First of all I want to say thank you for sharing your knowledge with other people. You have already helped me a lot.
I was wondering if there is a opportunity to get the name of the user that is running the journal. If I create a journal a header will appear with following details:
' NX 9.0.3.4
' Journal created by USERNAME on Tue Jun 30 17:59:48 2015 Mitteleuropäische Sommerzeit
Therefore NX knows who is running something. I would need to get the name as a variable without writing a journal for each person.
This brings me to a second question running NX with Teamcenter: Is it possible to interact with TC and read out the current user group and role?
I am from Germany and not that good at languages. Hopefully i wrote not to many mistakes in my question...
Best regards
re: user name
It is very easy to get the user's log in name (the value you see at the top of a recorded journal).
Option Strict Off
Imports System
Imports NXOpen
Module Module1
Sub Main()
Dim theSession As Session = Session.GetSession()
Dim lw As ListingWindow = theSession.ListingWindow
lw.Open()
lw.WriteLine("UserName: " & Environment.UserName)
lw.Close()
End Sub
Public Function GetUnloadOption(ByVal dummy As String) As Integer
'Unloads the image immediately after execution within NX
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
End Function
End Module
TC User Group and Role
This brings me to a second question running NX with Teamcenter: Is it possible to interact with TC and read out the current user group and role?
From GTAC:
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UI
Imports NXOpen.Utilities
Module report_current_login_group_and_role
Dim s As Session = Session.GetSession()
Sub Main()
Dim dbSessionOptions As PDM.SessionSettings = _
s.NewDatabaseSessionOptions()
Dim currentGroup As String = dbSessionOptions.Group()
Echo("Current Group: " & currentGroup)
Dim currentRole As String = dbSessionOptions.Role()
Echo("Current Role: " & currentRole)
End Sub
Sub Echo(ByVal output As String)
s.ListingWindow.Open()
s.ListingWindow.WriteLine(output)
s.LogFile.WriteLine(output)
End Sub
Public Function GetUnloadOption(ByVal dummy As String) As Integer
Return Session.LibraryUnloadOption.Immediately
End Function
End Module
Thank you
Wow, both examples work perfect after integration into the code, thank you so much!
Best Regards
But how to get TC user name
Hi folks,
I don't intend to hijack this topic but how do I get the currently logged in TC user name? (Not Windows environment)
Any clue would be very appreciated!
Kind regards from Switzerland,
Stefan