Welcome,
Guest
. Please
login
or
register
.
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News:
Home
Help
Login
Register
TheSwamp
»
Code Red
»
AutoLISP (Vanilla / Visual)
»
Topic:
Correct me if I'm wrong...but strcase sets case
« previous
next »
Print
Pages: [
1
] |
Go Down
Author
Topic: Correct me if I'm wrong...but strcase sets case (Read 1111 times)
0 Members and 1 Guest are viewing this topic.
jlogan02
Bull Frog
Posts: 327
Correct me if I'm wrong...but strcase sets case
«
on:
July 28, 2021, 04:51:00 PM »
Code - Auto/Visual Lisp:
[Select]
(
setq
tagname1
"DESIGNER"
)
(
setq
ss1
(
ssget
"x"
'
(
(
2
.
"TBLK_ATT_CTL"
)
(
66
.
1
)
)
)
)
(
repeat
(
setq
x
(
sslength
ss1
)
)
(
setq
obj1
(
vlax
-
ename
->
vla-object
(
ssname
ss1
(
setq
x
(
-
x
1
)
)
)
)
)
(
if
(
=
(
vla-get-hasattributes
obj
)
:vlax-true
)
(
foreach
att1
(
vlax-invoke
obj1 'getattributes
)
(
if
(
=
tagname1
(
strcase
(
vla-get-tagstring
att1
)
)
)
(
vla-put-textstring
att1
(
substr
(
getvar
"loginname"
)
1
3
)
)
)
)
)
)
In this code I'm setting the case of tagname1 to lower case. Correct?
I've tested 4 different users and tagname1 gets filled in with lowercase in all cases but mine. I checked their actual LogInName with
Code - Auto/Visual Lisp:
[Select]
getvar
and all were indeed lowercase except mine.
So it seems that I need to update their LogInName to be uppercase as the variable LogInName is read only. Or change the result of tagname1 after it's populated.
Logged
J. Logan
ACAD 2018
I am one with the Force and the Force is with me.
AutoCAD Map 2018 Windows 10
JohnK
Administrator
Seagull
Posts: 10648
Re: Correct me if I'm wrong...but strcase sets case
«
Reply #1 on:
July 28, 2021, 06:08:33 PM »
(strcase "Sample" T)
Specifying the
witch
as
true
will convert the string to lower case.
...click on the strcase function in your code block above to get the help for the function.
Logged
TheSwamp.org
(serving the CAD community since 2003)
Member location map - Add yourself
Donate to TheSwamp.org
jlogan02
Bull Frog
Posts: 327
Re: Correct me if I'm wrong...but strcase sets case
«
Reply #2 on:
July 28, 2021, 06:17:14 PM »
I did exactly that before I wrote the OP. It's clear to me, I read the help wrong.
Thanks for pointing that out,.
Logged
J. Logan
ACAD 2018
I am one with the Force and the Force is with me.
AutoCAD Map 2018 Windows 10
Lee Mac
Seagull
Posts: 12914
London, England
WWW
Re: Correct me if I'm wrong...but strcase sets case
«
Reply #3 on:
July 30, 2021, 01:03:46 PM »
Note that you are applying
strcase
to the attribute
tag
as returned by
vla-get-tagstring
in order to use a case-insensitive match between the attribute tag and the value held by the variable
tagname1
, not to the value that is used to populate the attribute.
I might suggest the following changes:
Code - Auto/Visual Lisp:
[Select]
(
setq
tag
"DESIGNER"
)
(
if
(
setq
sel
(
ssget
"_X"
'
(
(
0
.
"INSERT"
)
(
2
.
"TBLK_ATT_CTL"
)
(
66
.
1
)
)
)
)
(
repeat
(
setq
idx
(
sslength
sel
)
)
(
setq
idx
(
1-
idx
)
obj
(
vlax
-
ename
->
vla-object
(
ssname
sel idx
)
)
)
(
vl-some
'
(
lambda
(
att
)
(
if
(
and
(
=
tag
(
strcase
(
vla-get-tagstring
att
)
)
)
(
vlax-write-enabled-p
att
)
)
(
not
(
vla-put-textstring
att
(
strcase
(
substr
(
getvar
'loginname
)
1
3
)
t
)
)
)
)
)
(
vlax-invoke
obj 'getattributes
)
)
)
)
Here:
(0 . "INSERT")
is included in the ssget filter list
vl-some
will cease evaluation of the attributes when the target attribute is found
An
if
statement is used to verify that a valid selection exists
vlax-write-enabled-p
checks that the attribute can be modified (i.e. does not reside on a locked layer) prior to modification
Logged
Lee Mac Programming
•
Twitter
•
Exchange App Store
Print
Pages: [
1
] |
Go Up
« previous
next »
TheSwamp
»
Code Red
»
AutoLISP (Vanilla / Visual)
»
Topic:
Correct me if I'm wrong...but strcase sets case