Author Topic: Need help with filtering a list  (Read 314 times)

0 Members and 1 Guest are viewing this topic.

dubb

  • Swamp Rat
  • Posts: 1066
Need help with filtering a list
« 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.

Lee Mac

  • Seagull
  • Posts: 12285
  • London, England
Re: Need help with filtering a list
« Reply #1 on: July 01, 2019, 12:34:43 PM »
I would say that you need a 'group by key' 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. )

dubb

  • Swamp Rat
  • Posts: 1066
Re: Need help with filtering a list
« Reply #2 on: July 01, 2019, 12:44:37 PM »
Ah..thanks. That is  Genius!
I would say that you need a 'group by key' 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. )