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:
get from an list only the var name
« previous
next »
Print
Pages: [
1
] |
Go Down
Author
Topic: get from an list only the var name (Read 1390 times)
0 Members and 1 Guest are viewing this topic.
Humbertogo
Guest
get from an list only the var name
«
on:
July 10, 2012, 05:30:29 AM »
I have a list with variant
something like ("HEIGHT 01" . 1410.0) ("HEIGHT 02" . 1730.0) ("HEIGHT 03" . 1830.0) ("HEIGHT 04" . 1720.0) ("HEIGHT 05" . 1400.0)
i try to get from the list only the var name
Is there any way to handle this?
Thanks
Logged
irneb
Water Moccasin
Posts: 1794
ACad R9-2016, Revit Arch 6-2016
WWW
Re: get from an list only the var name
«
Reply #1 on:
July 10, 2012, 05:35:49 AM »
You mean you want the variable's symbol name to which this list is applied? Or are you referring to wanting something from a variant/safearray?
Sorry for my confusion, could you possibly post some sample code? Maybe then I'd be more enlightened :-[
Logged
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.
irneb
Water Moccasin
Posts: 1794
ACad R9-2016, Revit Arch 6-2016
WWW
Re: get from an list only the var name
«
Reply #2 on:
July 10, 2012, 05:39:38 AM »
The list in your post looks like an association list, the usual way of using this is like so:
Code - Auto/Visual Lisp:
[Select]
_$
(
setq
lst '
(
(
"HEIGHT 01"
.
1410.0
)
(
"HEIGHT 02"
.
1730.0
)
(
"HEIGHT 03"
.
1830.0
)
(
"HEIGHT 04"
.
1720.0
)
(
"HEIGHT 05"
.
1400.0
)
)
)
(
(
"HEIGHT 01"
.
1410.0
)
(
"HEIGHT 02"
.
1730.0
)
(
"HEIGHT 03"
.
1830.0
)
(
"HEIGHT 04"
.
1720.0
)
(
"HEIGHT 05"
.
1400.0
)
)
_$
(
cdr
(
assoc
"HEIGHT 03"
lst
)
)
1830.0
If by "var name" you're referring the to association keys, then perhaps:
Code - Auto/Visual Lisp:
[Select]
_$
(
mapcar
'
car
lst
)
(
"HEIGHT 01"
"HEIGHT 02"
"HEIGHT 03"
"HEIGHT 04"
"HEIGHT 05"
)
Logged
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.
Humbertogo
Guest
Re: get from an list only the var name
«
Reply #3 on:
July 10, 2012, 05:44:31 AM »
Thanks
that is exact what i need to do (mapcar 'car lst)
Logged
Print
Pages: [
1
] |
Go Up
« previous
next »
TheSwamp
»
Code Red
»
AutoLISP (Vanilla / Visual)
»
Topic:
get from an list only the var name