Author Topic: drill count with table  (Read 1078 times)

0 Members and 1 Guest are viewing this topic.

Crookedmonk

  • Newt
  • Posts: 30
drill count with table
« on: February 25, 2022, 11:53:23 AM »
Does anyone know of a routine that will count all holes(circles) and place them in a table with count #'s and sizes?

kpblc

  • Bull Frog
  • Posts: 396
Re: drill count with table
« Reply #1 on: February 25, 2022, 12:09:58 PM »
_.dataextraction ?
Sorry for my English.

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: drill count with table
« Reply #2 on: February 25, 2022, 04:21:09 PM »
Yup DataExtraction.  One of my favorites.
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

BIGAL

  • Swamp Rat
  • Posts: 1434
  • 40 + years of using Autocad
Re: drill count with table
« Reply #3 on: February 26, 2022, 07:31:48 PM »
Pretty easy a good learn lisp task. I have attached the 1st part which makes a blank table try it you will need to reduce columns etc you then use a INSERTROWS function and set the text.

Code: [Select]
(setq numrows (1+ numrows))
(vla-InsertRows Objtable  numrows (vla-GetRowHeight Objtable (1- numrows)) 1)
(vla-Settext Objtable  numrows 0 holenum )
(vla-Settext Objtable  numrows 1 Rad)

Post a sample dwg so can see how you want to label the circles.
« Last Edit: February 26, 2022, 10:31:55 PM by BIGAL »
A man who never made a mistake never made anything

Crookedmonk

  • Newt
  • Posts: 30
Re: drill count with table
« Reply #4 on: February 28, 2022, 08:01:21 AM »
This is what I was looking for. I tried _.DATAEXTRACTION but just get a table full of hole sizes. Does not show the total amount of hits.

BIGAL

  • Swamp Rat
  • Posts: 1434
  • 40 + years of using Autocad
Re: drill count with table
« Reply #5 on: March 01, 2022, 02:04:05 AM »
Try  this no power left will mod re table.

Code: [Select]
; Make a count of common items
; By AlanH Aug 2021

; http://www.theswamp.org/index.php?topic=57408.0


(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)))
  )
)

(defun c:cntcirc ( / ss rad val cnt lst2 lst3 sp curspace tot)

(setq ss (ssget '((0 . "CIRCLE"))))

(if (= ss nil)
(progn (Alert "no circles selected will exit ")(exit))
(progn
(setq lst '())
(repeat (setq x (sslength ss))
(setq rad (cdr (assoc 40 (entget (ssname ss (setq x (1- x)))))))
(setq lst (cons rad lst))
)
)
)

(setq lst2 (remove_doubles lst))
(foreach val lst2
(setq cnt (my-count val lst))
(setq lst3 (cons (list  val cnt) lst3))
)

(setq lst3 (vl-sort lst3 '(lambda (x y) (< (car x)(car y)))))

(setq sp (vlax-3d-point (getpoint "pick a point for table")))

(Setq curspace (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))))

(setq numrows 3)
(setq numcolumns 2)
(setq rowheight 1)
(setq colwidth 5)
(setq objtable (vla-addtable curspace sp numrows numcolumns rowheight colwidth))
(vla-settext objtable 0 0 "HIT COUNT")
(vla-settext objtable 1 0 "DIA")
(vla-settext objtable 1 1 "TOTAL COUNT")
(command "_zoom" "e")
(setq Objtable (vlax-ename->vla-object (entlast)))
(setq Objtable (vlax-ename->vla-object (entlast)))
(vla-setcellalignment objtable 2 0 acMiddleCenter)
(vla-setcellalignment objtable 2 1 acMiddleCenter)

(vla-put-regeneratetablesuppressed Objtable :vlax-true)


(foreach val lst3
(vla-InsertRows Objtable  numrows (vla-GetRowHeight Objtable (1- numrows)) 1)
(vla-Settext Objtable  numrows 0  (nth 0 val))
(vla-Settext Objtable  numrows 1 (nth 1 val))
(vla-setcellalignment objtable numrows 0 acMiddleCenter)
(vla-setcellalignment objtable numrows 1 acMiddleCenter)
(setq numrows (1+ numrows))
)

(vla-InsertRows Objtable  numrows (vla-GetRowHeight Objtable (1- numrows)) 1)
(setq numrows (1+ numrows))
(vla-InsertRows Objtable  numrows (vla-GetRowHeight Objtable (1- numrows)) 1)

(vla-setcellalignment objtable numrows 1 acMiddleCenter)
(setq tot 0)
(foreach val lst3
(setq tot (+ tot (cadr val)))
)
(vla-Settext Objtable  numrows 1 tot)

(vla-put-regeneratetablesuppressed Objtable :vlax-false)

(princ)
)

(c:cntcirc)

A man who never made a mistake never made anything