Author Topic: get from an list only the var name  (Read 205 times)

0 Members and 1 Guest are viewing this topic.

Humbertogo

  • Newt
  • Posts: 176
get from an list only the var name
« on: July 10, 2012, 04: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

  • Swamp Rat
  • Posts: 1210
  • ACad R9-2013, Revit Arch 6-2013
Re: get from an list only the var name
« Reply #1 on: July 10, 2012, 04: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

  • Swamp Rat
  • Posts: 1210
  • ACad R9-2013, Revit Arch 6-2013
Re: get from an list only the var name
« Reply #2 on: July 10, 2012, 04: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

  • Newt
  • Posts: 176
Re: get from an list only the var name
« Reply #3 on: July 10, 2012, 04:44:31 am »
Thanks
that is exact what  i need to do (mapcar 'car lst)