Hi everyone.
We wanted to get the active user name, so we created a test code like this.
# Fusion360API Python script
import adsk.core, adsk.fusion, traceback
def run(context):
ui :adsk.core.UserInterface = None
try:
app :adsk.core.Application = adsk.core.Application.get()
ui = app.userInterface
user = app.currentUser
info = [
f'displayName : {user.displayName}',
f'userName :{user.userName}',
f'userId :{user.userId}',
f'email :{user.email}',
]
ui.messageBox('\n'.join(info))
except:
if ui:
print('Failed:\n{}'.format(traceback.format_exc()))
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
Looking at the description of the displayName property, I thought I could get it with displayName.
https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-2CD5E1DC-A891-4893-AFC0-17224F2B765B
The result is shown in the upper left of the image.
What is retrieved by displayName is the user name displayed in "My Profile".
Does anyone know how to get the user name displayed in the Fusion360 user interface?
Thank you in advance.
Solved! Go to Solution.
Solved by JeromeBriot. Go to Solution.
Hi,
Maybe :
import adsk.core
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
userName = app.executeTextCommand('Options.Get LastFullUserNameId').split(" has value ")[-1]
ui.messageBox(userName)
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
I can't test because this is the same name on my profile and on the Fusion 360 UI.
Jérôme Briot, Freelance engineer - Mechanical design and prototyping
3D Print Plus / Pro | IDF Import | GitHub To Fusion 360 | Tube Bending Data Exchanger | Slice Data Export
Memory Used | Basic Calculator | Check Computer Specifications | Import spline from any CSV file