<property# Username on Application>

<property# Username on Application>

jagostinho74
Collaborator Collaborator
959 Views
3 Replies
Message 1 of 4

<property# Username on Application>

jagostinho74
Collaborator
Collaborator

Hello,

 

getting 

<property# Username on Application>
instead of the actual username while using 
 
from pyrevit import ApplicationServices
 
username = ApplicationServices.Application.Username
 
print username
 
any ideas?
 
Thank you
J
Assistant BIM/CAD Manager

Manchester, UK


0 Likes
Accepted solutions (1)
960 Views
3 Replies
Replies (3)
Message 2 of 4

TorsionTools
Contributor
Contributor

You need to use the UIApplication.

 

UIApplication uiapp = commandData.Application;
string user = uiapp.Application.Username;

You an use the ApplicationServices method to make sure a user is logged in.

UIApplication uiapp = commandData.Application;
if (Autodesk.Revit.ApplicationServices.Application.IsLoggedIn)
{
string user = uiapp.Application.Username;
}

 

Message 3 of 4

jagostinho74
Collaborator
Collaborator

how can I define "commandData"?

 

Getting this error.

 

NameError: name 'commandData' is not defined

 

Assistant BIM/CAD Manager

Manchester, UK


0 Likes
Message 4 of 4

TorsionTools
Contributor
Contributor
Accepted solution

That was showing an example of how to get the UIApplication from an ExternalCommand. Just make sure you have the UIApplication and you can get the information you are looking for.

0 Likes