BOLT COUNTING BY LAYER

BOLT COUNTING BY LAYER

Gaganpatel
Collaborator Collaborator
1,684 Views
29 Replies
Message 1 of 30

BOLT COUNTING BY LAYER

Gaganpatel
Collaborator
Collaborator

Dear Sir,

 

I want to bolt counting by layer, counting only select text (after & before)

Please see the attached file.

Layer Name : BN1 x 1=

Layer Name : BN2 x 2=

Layer Name : BN3 x 3=

Layer Name : BN4 x 4=

 

Total Quality : = BN1+BN2+BN3+BN4

M16x35mm =

M16x40mm =

M16x45mm =

M16x50mm =

M16x55mm =

4 Thk Washer =

5 Thk Washer =

6 Thk Washer =

8 Thk Washer =

10 Thk Washer =

 

 

 

0 Likes
Accepted solutions (1)
1,685 Views
29 Replies
Replies (29)
Message 2 of 30

Gaganpatel
Collaborator
Collaborator

Dear Sir,

 

Anybody please help me

 

0 Likes
Message 3 of 30

ec-cad
Collaborator
Collaborator

Try this Lisp out. Do an Appload of it from disk. (files of type '.lsp').

When loaded, just type GO to start the program.

I hope this gets you started.

 

ECCAD

0 Likes
Message 4 of 30

ec-cad
Collaborator
Collaborator

Oh, forgot to mention, it doesn't (output) the results, just echo's them to the TextScreen.

If you don't see anything happen, just hit the F2 key to throw up the TextScreen.

If you need a Table built, maybe someone here will do that. Or if you need a .csv file for Excel,

I'm sure someone can do that also.

 

ECCAD

0 Likes
Message 5 of 30

ec-cad
Collaborator
Collaborator

Hmm,

I see some 8-20x45 's in there. Are there more bolt sizes than were mentioned in Post ?

 

ECCAD

0 Likes
Message 6 of 30

Gaganpatel
Collaborator
Collaborator

Dear Sir,

 

Thanks for reply.

 

I want to many types bolts counting, select person bolts counting only not complete drawing bolts count, final total qty. place in text select location in auto cad drawing.

Types of Bolts & Washer

1) M16x35 to M16x130 (bolts)

2) M20x35 to M20X180 (bolts)

3) M24x40 to M24x190 (bolts)

4) M16 4tHK to M16 12THK (washer)

4) M20 4tHK to M20 12THK (washer)

4) M24 4tHK to M20 12THK (washer)

 

0 Likes
Message 7 of 30

Sea-Haven
Mentor
Mentor

Another makes table.

; https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/bolt-counting-by-layer/td-p/12726828

(defun c:boltcnt ( / ss ent str pos num1 str2 lst lst2 lst3 numrows numcolumns rowheight colwidth doc curspc pt )
(setq ss (ssget '((0 . "TEXT"))))
(setq lst '())
(repeat (setq x (sslength ss))
(setq ent (ssname ss (setq x (1- x))))
(setq str (cdr (assoc 1 (entget ent))))
(setq pos (vl-string-position 45 str))
(setq num1 (atoi (substr str 1 pos)))
(setq str2 (substr str (+ 2 pos)))
(repeat num1
(setq lst (cons str2 lst))
)
)

(setq lst (vl-sort lst '(lambda (x y) (< x y))))

(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 lst2 '() lst3 '())
(setq lst2 (remove_doubles lst))
(foreach val lst2
    (setq cnt (my-count val lst))
    (setq lst3 (cons (list val cnt) lst3))
)


(setq numrows 3)
(setq numcolumns 2)
(setq rowheight 8)
(setq colwidth 40)

(setq doc  (vla-get-activedocument (vlax-get-acad-object) ))
(if (= (vla-get-activespace doc) 0)
(setq curspc (vla-get-paperspace doc))
(setq curspc (vla-get-modelspace doc))
)

(setq pt (vlax-3d-point (getpoint "\nPick point for table ")))

(setq objtable (vla-addtable curspc pt numrows numcolumns rowheight colwidth))
(vla-setcellalignment objtable 0 0 acMiddleCenter)
(vla-setcellalignment objtable 1 0 acMiddleCenter)
(vla-setcellalignment objtable 1 1 acMiddleCenter)
(vla-setcellalignment objtable 2 0 acMiddleCenter)
(vla-setcellalignment objtable 2 1 acMiddleCenter)
(vla-SetTextHeight objtable acHeaderRow 3)
(vla-SetTextHeight objtable acTitleRow 3)
(vla-SetTextHeight objtable acDataRow 3)
(vla-settext objtable 0 0 "Bolt table")
(vla-settext objtable 1 0 "Bolt size")
(vla-settext objtable 1 1 "Count")
(setq objtable (vlax-ename->vla-object (entlast)))

(vla-put-regeneratetablesuppressed objtable :vlax-true)
(setq objtable (vla-addtable curspc pt numrows numcolumns rowheight colwidth))
(vla-SetAlignment Objtable (+ acDataRow acHeaderRow acTitleRow) acMiddleCenter)
(vla-SetTextHeight objtable (+ acDataRow acHeaderRow acTitleRow) 3)
(vla-settext objtable 0 0 "Bolt table")
(vla-settext objtable 1 0 "Bolt size")
(vla-settext objtable 1 1 "Count")
(setq objtable (vlax-ename->vla-object (entlast)))
(setq rows 2)
(foreach cellline lst3
(vla-insertrows objtable rows 8 1)
(vla-settext objtable rows 0 (car cellline))
(vla-settext objtable rows 1 (rtos (cadr cellline) 2 0))
(vla-SetcelltextHeight objtable rows 0 3)
(vla-SetcellTextHeight objtable rows 1 3)
(vla-SetcellAlignment objtable rows 0 acMiddleCenter)
(vla-SetcellAlignment objtable rows 1 acMiddleCenter)
(setq rows (1+ rows))
)

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

(princ)
)
(c:boltcnt)
0 Likes
Message 8 of 30

Gaganpatel
Collaborator
Collaborator

Dear Sir,

 

Thanks for reply.

AutoCAD 2013 use . Output Bolt qty not show only table show.

0 Likes
Message 9 of 30

ec-cad
Collaborator
Collaborator

This Lisp will count bolts & washers per your new list of bolt & washer sizes. Lots of Counters in there.

Attached is the Lisp and a sample drawing.

Do an Appload (files of type .lsp), when loaded, just type GO to call the function.

It will count up the totals and ask you to pick a point to add-in the Text report.

If the Text height is too large, let me know..I based that on the sample drawing.

Hope you like it.

ECCAD

0 Likes
Message 10 of 30

ec-cad
Collaborator
Collaborator

Minor correction for one of the M24 counters. Fixed that.

Here's the final version.

 

ECCAD

0 Likes
Message 11 of 30

Gaganpatel
Collaborator
Collaborator

Dear Sir,

 

Many Many Thanks

 

Please do some modification.
Not total bolt counting on the drawing sheet, only select bolt counting on the drawing sheet.

0 Likes
Message 12 of 30

Sea-Haven
Mentor
Mentor

This is what I get

SeaHaven_0-1714012919585.png

Added more bolts for a better count

SeaHaven_1-1714012954203.png

The table needs to be scaled up as I guessed the size.

0 Likes
Message 13 of 30

ec-cad
Collaborator
Collaborator

Sure. You now 'pick upper left, and lower right points. Program will get the text to process in the

Selection Window points. Will list all bolts / washers just within the Window on the Layers BN1 BN2 BN3 BN4.

If you need anything else, just let me know.

 

ECCAD

0 Likes
Message 14 of 30

Gaganpatel
Collaborator
Collaborator

Dear sir,

 

I have tried select first window point uper left and other window point lower right but text are not selected output results not showing.

0 Likes
Message 15 of 30

Gaganpatel
Collaborator
Collaborator

Dear Sir,

 

Only table create not bolt counting, One modify please select required only Bolt Text not other text.

Gaganpatel_0-1714018361627.png

 

0 Likes
Message 16 of 30

ec-cad
Collaborator
Collaborator

When I added the Window selection, I didn't filter out all but Text. This update will work as expected.

Sorry about that. My bad.

ECCAD

0 Likes
Message 17 of 30

Gaganpatel
Collaborator
Collaborator

Dear Sir,

Please some modification required.

Change Layer: select Bolt text choose layer name Option:BN1 BN2 BN3 BN4

0 Likes
Message 18 of 30

ec-cad
Collaborator
Collaborator

I do not understand the question.

You wanted to get the count by selecting those items. That I did.

Do you want to select just some items within that window, by specifying which Layer ?

If so, I need to ask you which layer 1, 2, 3 or 4 ? That I can do. You would get a total count for those

that are on (1) layer. You would have to run it 4 times to get a total count, unless an option would

be 1,2,3,4 or A for all. So, what is it you need ?

 

ECCAD

0 Likes
Message 19 of 30

Gaganpatel
Collaborator
Collaborator

Dear Sir,
I want to new programming for layer change of bolt text .

 

0 Likes
Message 20 of 30

ec-cad
Collaborator
Collaborator

Could you make up a drawing of  "layer change of bolt text". to show me what you mean exactly.

What layer do you want me to 'change' it to ?

I'm confused.

ECCAD

0 Likes