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

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
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  :-[
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
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]
  1. _$ (setq lst '(("HEIGHT 01" . 1410.0) ("HEIGHT 02" . 1730.0) ("HEIGHT 03" . 1830.0) ("HEIGHT 04" . 1720.0) ("HEIGHT 05" . 1400.0)))
  2. (("HEIGHT 01" . 1410.0) ("HEIGHT 02" . 1730.0) ("HEIGHT 03" . 1830.0) ("HEIGHT 04" . 1720.0) ("HEIGHT 05" . 1400.0))
  3. _$ (cdr (assoc "HEIGHT 03" lst))
  4. 1830.0
If by "var name" you're referring the to association keys, then perhaps:
Code - Auto/Visual Lisp: [Select]
  1. _$ (mapcar 'car lst)
  2. ("HEIGHT 01" "HEIGHT 02" "HEIGHT 03" "HEIGHT 04" "HEIGHT 05")
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)