TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: dubb on July 01, 2019, 12:23:47 PM

Title: Need help with filtering a list
Post by: dubb on July 01, 2019, 12:23:47 PM
I'm trying to develop a check list in AutoCAD. Each item in the check list could have one header/section. The check list would be stored in a text/csv format.

The general idea of each item in the list are.
Code: [Select]
("Group" "Task" "Status")
Using Lee's ReadCSV function the results of the list below:

Code: [Select]
(("Group" "Task" "Status")("Rev1" "Task1" "Incomplete")("Rev1" "Task2" "Incomplete")("Rev1" "Task3" "Incomplete")("Rev2" "Task 1" "Incomplete")("Rev2" "Task 2" "Incomplete"))
The end goal below would be to generate a dcl with check boxes for each task:

Rev1
Task1 Incomplete
Task2 Incomplete
Task3 Incomplete
Rev2
Task1 Incomplete
Task2 Incomplete

I'm having difficulty with my lack of understanding how to use vl-remove I think that's the approach I need to take.
Title: Re: Need help with filtering a list
Post by: Lee Mac on July 01, 2019, 12:34:43 PM
I would say that you need a 'group by key' (https://www.theswamp.org/index.php?topic=53515.msg582150#msg582150) function, e.g.:
Code - Auto/Visual Lisp: [Select]
  1. _$ (groupbykey '(("Group" "Task" "Status") ... ("Rev2" "Task 2" "Incomplete")))
  2. (
  3.     ("Group"
  4.         ("Task" "Status")
  5.     )
  6.     ("Rev1"
  7.         ("Task1" "Incomplete")
  8.         ("Task2" "Incomplete")
  9.         ("Task3" "Incomplete")
  10.     )
  11.     ("Rev2"
  12.         ("Task 1" "Incomplete")
  13.         ("Task 2" "Incomplete")
  14.     )
  15. )
Title: Re: Need help with filtering a list
Post by: dubb on July 01, 2019, 12:44:37 PM
Ah..thanks. That is  Genius!
I would say that you need a 'group by key' (https://www.theswamp.org/index.php?topic=53515.msg582150#msg582150) function, e.g.:
Code - Auto/Visual Lisp: [Select]
  1. _$ (groupbykey '(("Group" "Task" "Status") ... ("Rev2" "Task 2" "Incomplete")))
  2. (
  3.     ("Group"
  4.         ("Task" "Status")
  5.     )
  6.     ("Rev1"
  7.         ("Task1" "Incomplete")
  8.         ("Task2" "Incomplete")
  9.         ("Task3" "Incomplete")
  10.     )
  11.     ("Rev2"
  12.         ("Task 1" "Incomplete")
  13.         ("Task 2" "Incomplete")
  14.     )
  15. )