Jump to content

Lisp to count text and layers


ancrayzy

Recommended Posts

Lots like me happy to do a custom lisp, but need beer money. Or have a go at adding layer to Lee's code.

 

If you want to hve a go 

ssget the text

create a list of layer name and text string

remove duplicates and count

 

This is the core bits to get what you want thanks to Gile. The lst5 is the result that is used in making a table.

 

 

; Make a count of common items 
; By AlanH Aug 2021
(vl-load-com)
; By Gile
(defun my-count (a L)
  (cond
   ((null L) 0)
   ((equal a (car L)) (+ 1 (my-count a (cdr L))))
   (t (my-count a (cdr L))))
)

; By Gile
(defun remove_doubles (lst)
  (if lst
    (cons (car lst) (remove_doubles (vl-remove (car lst) lst)))
  )
)

 

(setq lst4(remove_doubles lstube))
(foreach val lst4
(setq cnt (my-count val lstube))
(setq lst5 (cons (list (/ cnt 2)(nth 0 val )(nth 1 val))lst5))
)

 

Yes I have something but would need to remove all the un necessary bits in the code.

Edited by BIGAL
  • Like 1
Link to comment
Share on other sites

Many thanks @BIGAL for your reply, but i still don't know how to use your code.

The result maybe like this. 

And it would be great to add the option to scale the table before exporting the results

 

image.png.be2d8b99c4175acf78ac206527d92af2.png

Edited by ancrayzy
Missing information
Link to comment
Share on other sites

Above my coding knowledge once lambda & mapcar show up really need to sit down and learn those.

I know at least @Tharwat can remember his password. maybe he will poke his head in here.

🤣 (Se7en)

Edited by mhupp
  • Like 1
  • Funny 1
Link to comment
Share on other sites

1 hour ago, mhupp said:

Above my coding knowledge once lambda & mapcar show up really need to sit down and learn those.

I know at least @Tharwat can remember his password. maybe he will poke his head in here.

🤣 (Se7en)

Thank you so much Mr @mhupp

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...