Insert fields, initials, from Login

Insert fields, initials, from Login

Anonymous
Not applicable
1,658 Views
14 Replies
Message 1 of 15

Insert fields, initials, from Login

Anonymous
Not applicable

I would like to extract someones initials, first and last letter, from their Login.

 

%<\AcVar Login \f "%UC2">%

- Gives me SURNAME, NAME

 

%<\AcDiesel $(substr, $(getvar, "LOGINNAME"),1,3)>%

- Gives me the loginname (based on the string etc), which is SurnameN.

 

I'd much prefer to have it based on Login (rather than loginname), and have it pick the first letter in each word, but backwards (spelling NS). Alternatively, last and first in the loginname.

 

Hope it makes sense. Any ideas?

 

PS. I don't speak Diesel/Code, but I can make sense of some of it. 🙂 DS.

0 Likes
1,659 Views
14 Replies
Replies (14)
Message 2 of 15

Anonymous
Not applicable

Is LOGIN an environment variable set outside AutoCAD in your operating system? I'm not able to reproduce the outcome of %<\AcVar Login \f "%UC2">% on my environment.

 

With friendly greetings, M. Moolhuysen.

0 Likes
Message 3 of 15

hmsilva
Mentor
Mentor

@Anonymous wrote:

Is LOGIN an environment variable set outside AutoCAD in your operating system? I'm not able to reproduce the outcome of %<\AcVar Login \f "%UC2">% on my environment.

 

With friendly greetings, M. Moolhuysen.


Hi M. Moolhuysen,

 

try:

Command field -> Field Category = Plot -> Format = none

 

Hope this helps,
Henrique

EESignature

0 Likes
Message 4 of 15

hmsilva
Mentor
Mentor

@Anonymous wrote:

I would like to extract someones initials, first and last letter, from their Login.

 

%<\AcVar Login \f "%UC2">%

- Gives me SURNAME, NAME

 

%<\AcDiesel $(substr, $(getvar, "LOGINNAME"),1,3)>%

- Gives me the loginname (based on the string etc), which is SurnameN.

 

I'd much prefer to have it based on Login (rather than loginname), and have it pick the first letter in each word, but backwards (spelling NS). Alternatively, last and first in the loginname.

 

Hope it makes sense. Any ideas?

 

PS. I don't speak Diesel/Code, but I can make sense of some of it. 🙂 DS.


Hi anderslindgreen,

if the return from (getvar, LOGINNAME) is 'SurnameN', perhaps anything like this will do the trick:

 

$(substr, $(getvar, loginname),$(strlen, $(getvar, loginname)),1)$(substr, $(getvar, loginname), 2, 1,)

 

Hope this helps,
Henrique

EESignature

0 Likes
Message 5 of 15

miketUYKB6
Contributor
Contributor

apologies for not being fluent in diesel, but how would you rearrange this code to have the first name initial first and the last name initial last??  Thank you for your help.

0 Likes
Message 6 of 15

ronjonp
Mentor
Mentor

Try this: 

$(substr, $(getvar, loginname), 2, 1,)$(substr, $(getvar, loginname),$(strlen, $(getvar, loginname)),1)

In lisp:

(strcat (substr (setq ln (getvar 'loginname)) 1 1) (substr ln (strlen ln)))
Message 7 of 15

miketUYKB6
Contributor
Contributor
Thank you! that was exactly what I needed.
0 Likes
Message 8 of 15

ronjonp
Mentor
Mentor

@miketUYKB6 wrote:
Thank you! that was exactly what I needed.

Glad to help 🙂

0 Likes
Message 9 of 15

ewestmark
Contributor
Contributor

so this solution ended up being super close to what I'm trying to do. Do you know how make it appear as first initial, period, space, full last name? (ex: "J. DOE")

thanks in advance

0 Likes
Message 10 of 15

Sea-Haven
Mentor
Mentor

Good time to learn in lisp example by ronjonp you can add "." to the strcat will leave it to you to work out.

0 Likes
Message 11 of 15

ronjonp
Mentor
Mentor

@ewestmark wrote:

so this solution ended up being super close to what I'm trying to do. Do you know how make it appear as first initial, period, space, full last name? (ex: "J. DOE")

thanks in advance


@ewestmark 

What does this return on your computer?
(alert (getvar 'loginname) )

0 Likes
Message 12 of 15

ewestmark
Contributor
Contributor
looks like it does not give my full name, which would explain my issue. I think it is sourcing my username, when what I want is my account's display name/common name. I think my confusion came from the field name "login" sourcing it correctly (though it wont let me modify it). so I guess my question becomes this:
Do you have any ideas what the variable list name I'm looking for might be?
0 Likes
Message 13 of 15

ewestmark
Contributor
Contributor
I just came across "onlineusername" which sources off email, which happens to be in a consistent jdoe@companyname format. so if I can figure out how to insert ". " after the first character, and also delete the last 14 characters, I should be in buisness
0 Likes
Message 14 of 15

ewestmark
Contributor
Contributor

update: I figured out how to format it, but it turns out I'm the only one who uses my company email as an onlineusername, so it is, in fact, not a reliable way to source the names...

 

if anyone is interested in what I came up with, it's this. I'm gonna go take a break, haha

$(upper,$(substr,$(getvar,onlineusername),3,1,)". "$(upper,$(substr,$(getvar,onlineusername),2,$(-,$(strlen,$(getvar,onlineusername)),15))

 

0 Likes
Message 15 of 15

Sea-Haven
Mentor
Mentor

Much easier to use a look up procedure you can use login name JD123 = J.Doe

 

 You make a list containing multiple 2 items ((userlogin actualname)..... I was AH1072. Just use foreach and search the list.

0 Likes