A Tabasi Posted December 26, 2023 Author Posted December 26, 2023 thanks a lot BIGAL I am waiting for your help Quote
BIGAL Posted December 30, 2023 Posted December 30, 2023 (edited) Try this, given time involved it borders on a commercial answer. So if you find it meets your needs a Beer donation would be welcome. ; https://www.cadtutor.net/forum/topic/78788-rebar-numbering/ ; By AlanH DEC 2023 ; Count bars base on size ; By Gile (defun compare-elements (a b sortspec) ( (lambda (x y test) (if (and (equal x y ) (cdr sortspec)) (compare-elements a b (cdr sortspec)) (apply test (list x y)) ) ) (nth (cdar sortspec) a) (nth (cdar sortspec) b) (caar sortspec) ) ) (defun complex-sort (alst sortspec) (vl-sort alst '(lambda (a b) (compare-elements a b sortspec) ) ) ) (defun comparelems ( / ) (if (and (= (nth 0 ans)(nth 0 ans2)) (= (nth 1 ans)(nth 1 ans2)) (= (nth 2 ans)(nth 2 ans2)) ) (setq tot (+ tot 1)) ) ) (defun comparelems2 ( / ) (if (and (= (nth 0 ans)(nth 0 ans2)) (= (nth 1 ans)(nth 1 ans2)) (= (nth 2 ans)(nth 2 ans2)) (= (nth 3 ans)(nth 3 ans2)) ) (setq tot (+ tot 1)) (AH:gotable ) ) ) (defun AH:gotable ( / txt) (setq rownum (vla-get-rows obj2)) (vla-InsertRows obj2 rownum (vla-GetRowHeight obj2 (- rownum 1)) 1) (repeat (setq k (length ans)) (setq txt (nth (setq k (- k 1)) ans)) (vla-settext obj2 rownum k txt) ) (vla-settext obj2 rownum 4 (rtos tot 2 0)) (setq tot 1) ) (defun AH:table_make ( / numrows curspc colwidth numcolumns objtable rowheight sp doc) (vl-load-com) (setq sp (vlax-3d-point (getpoint "Pick top left point for table "))) (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 dic (dictsearch (namedobjdict) "acad_tablestyle")) (setq dictabs (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 3)) dic))) (if (member "myTableStyle" dictabs) (princ "tablestyle exists") (progn (setq tblStlObj (vla-addobject (vla-add (vla-get-dictionaries doc) "ACAD_TABLESTYLE") "myTableStyle" "AcDbTableStyle" ) ) (vla-put-horzcellmargin tblStlObj 25) (vla-put-vertcellmargin tblStlObj 25) (vla-settextheight tblStlObj actitlerow 200) (vla-settextheight tblStlObj acheaderrow 200) (vla-settextheight tblStlObj acdatarow 200) (vla-SetAlignment tblStlObj (+ acDataRow acHeaderRow acTitleRow) acMiddleCenter) (vla-SetTextStyle tblStlObj (+ acDataRow acHeaderRow acTitleRow) "Standard") ) ) (setvar 'ctablestyle "myTableStyle") (setq numrows 2) (setq numcolumns 5) (setq rowheight 250) (setq colwidth 2500) (setq objtable (vla-addtable curspc sp numrows numcolumns rowheight colwidth)) (vla-settext objtable 0 0 "TABLE title") (vla-settext objtable 1 0 "A") (vla-settext objtable 1 1 "B") (vla-settext objtable 1 2 "C") (vla-settext objtable 1 3 "D") (vla-settext objtable 1 4 "Count") (vla-SetColumnWidth objtable 1 1500) (vla-SetColumnWidth objtable 2 1200) (vla-SetColumnWidth objtable 3 1000) (vla-SetColumnWidth objtable 4 1000) (setq objtable (entlast)) (princ) ) (defun c:barcnt ( / ss lst tot ent atts att ent1 x mld obj) (setq ss (ssget "X" (list (cons 0 "MULTILEADER")(cons 8 "rebar Tag")(cons 410 "Model")))) (setq lst '()) (repeat (setq x (sslength ss)) (setq ent (entget (ssname ss (setq x (1- x))))) (setq atts (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 302)) ent))) (setq atts (list (nth 1 atts)(nth 2 atts)(nth 3 atts) (cdr (assoc -1 ent)))) (setq lst (cons atts lst)) ) (setq lst (complex-sort lst '((< . 0) (< . 1) (< . 2)))) (setq x 0) (setq tot 1) (setq ans (nth x lst)) (repeat (- (length lst) 1) (setq ans2 (nth (setq x (+ x 1)) lst)) (if (and (= (nth 0 ans)(nth 0 ans2)) (= (nth 1 ans)(nth 1 ans2)) (= (nth 2 ans)(nth 2 ans2)) ) (progn (setq mld (vlax-ename->vla-object (nth 3 ans))) (vlax-for obj (vla-item (vla-get-blocks (vla-get-document mld)) (vla-get-contentblockname mld)) (if (and (= "AcDbAttributeDefinition" (vla-get-objectname obj)) (= :vlax-false (vla-get-constant obj)) ) (progn (setq oid (vla-get-objectid obj)) (if (= (vla-get-tagstring obj) "POS") (vla-setblockattributevalue mld oid (rtos tot 2 0) ) ) ) ) ) ) (progn (setq mld (vlax-ename->vla-object (nth 3 ans))) (vlax-for obj (vla-item (vla-get-blocks (vla-get-document mld)) (vla-get-contentblockname mld)) (if (and (= "AcDbAttributeDefinition" (vla-get-objectname obj)) (= :vlax-false (vla-get-constant obj)) ) (progn (setq oid (vla-get-objectid obj)) (if (= (vla-get-tagstring obj) "POS") (vla-setblockattributevalue mld oid (rtos tot 2 0) ) ) ) ) ) (setq tot (1+ tot) ) ) ) (setq ans ans2) ) (setq lst5 '()) (repeat (setq x (sslength ss)) (setq ent (entget (ssname ss (setq x (1- x))))) (setq atts (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 302)) ent))) (setq atts (list (nth 1 atts)(nth 2 atts)(nth 3 atts) (nth 4 atts))) (setq lst5 (cons atts lst5)) ) (setq lst5 (complex-sort lst5 '((< . 0) (< . 1) (< . 2)(< . 3)))) (AH:table_make) (setq obj2 (vlax-ename->vla-object (entlast))) (vla-put-regeneratetablesuppressed obj2 :vlax-true) (setq x 0) (setq tot 1) (setq ans (nth x lst5)) (repeat (- (length lst5) 1) (setq ans2 (nth (setq x (+ x 1)) lst5)) (comparelems2) (setq ans ans2) ) (AH:gotable) (vla-put-regeneratetablesuppressed obj2 :vlax-false) (princ) ) (c:barcnt) Please check the table answer carefully, I have not cross checked as to many values. Remove the "X" in this line will let you select and make smaller tables for checking. (setq ss (ssget "X" (list (cons 0 "MULTILEADER")(cons 8 "rebar Tag")(cons 410 "Model")))) Edited December 30, 2023 by BIGAL Quote
A Tabasi Posted December 30, 2023 Author Posted December 30, 2023 Thanks very much, BIGAL, I will use this code and say the result. Anyway, You a big help to me and I should buy a Beer for you However, you need to tell me how to pay for it. Quote
BIGAL Posted December 30, 2023 Posted December 30, 2023 Please check carefully that it is doing what you want it to do and let me know. Have an easy way for beer donation. Quote
A Tabasi Posted December 30, 2023 Author Posted December 30, 2023 again I had an error when loading the LISP code. I think I need to download the Lisp Code with a file lisp. Please send this code in LSP format. "Cannot invoke (command) from *error* without prior call to (*push-error-using-command*). Converting (command) calls to (command-s) is recommended." You don't know about the hardships of living in a country like Iran. It is very difficult and impossible for ordinary people to transfer money abroad. That's why I want you to tell me how I should serve you Beer. Quote
BIGAL Posted December 30, 2023 Posted December 30, 2023 Lisp file. Do you have access to Paypal ? Easy way to donate. Barcount.lsp Quote
A Tabasi Posted December 31, 2023 Author Posted December 31, 2023 Thank you I do not have PayPal or any debit card for transferring money, here is IRAN. It is not supported in my country. so I want to pay for your Beer, but I don't know how to do it. Quote
BIGAL Posted December 31, 2023 Posted December 31, 2023 Ok just make sure it works correctly. 1 Quote
A Tabasi Posted January 1 Author Posted January 1 (edited) Happy New Year I Wish best happens in the new year for you I checked this lisp, that's great. Although it's improved over the first version, there are still a few issues. For example; 1- Different numbers are assigned for similar rebars. a part of this problem is related to visibility states rebar block. actually "L1 shape" and "L shape" both of them have similar shapes. As a result, we should find a solution for this. 2- Also I saw that "Smooth Shape" Rebars have different marks for similar rebars. I don't understand why this problem has been created. 3-sometimes maybe should we need to mark the Rebars of the beam to the beam. so It will be better When LISP is loaded, before creating the final table, the user selects specific rebars and tags for the assignment mark, and then the final table is created by LISP. Finally, I would like to express my gratitude for your cooperation and help in this process. Edited January 1 by A Tabasi Quote
BIGAL Posted January 1 Posted January 1 "1- Different numbers are assigned for similar rebars" ? Each bar is sorted based on bar type, length and bundle number of bars, this is reflected in the count column. You need to supply an example table say for the top beam in your sample dwg. 2- Also I saw that "Smooth Shape" Rebars have different marks for similar rebars, The bars have different groups like a L=5.00M can have 3T10 or 3T20. 3 Can look into adding beam ID. Quote
A Tabasi Posted January 2 Author Posted January 2 1- I mean some Rebars by the Same Identity have different marks. Please look at the file attached in the table that has Revcloud. 2-although the bars have different groups, in same groups have different marks. for example; L=5.00m 5T20 , mark is 34 while L=5.00m 6T20, mark is 35 ! Both of them are Smooth Shapes. it's not correct. 3- I don't understand what you mean. I want in the file that has many beams, I do numbering bars beam to beam Test Lisp -new version.dwg Quote
BIGAL Posted January 2 Posted January 2 Ok I think I understand, say the - Shape L=8.7m becomes say 10 with count 2, please confirm. 1 Quote
BIGAL Posted January 8 Posted January 8 (edited) You did not confirm see post above only want to do once. Match common name and length and get total count. Ignore 2xT20 2xT16 etc Edited January 8 by BIGAL Quote
BIGAL Posted January 17 Posted January 17 (edited) Found some time and found a few more things to fix. Need sort on length, need to check for 7.5 & 7.50, fix ID number. So will be back. Please let me know if that is what your looking for that is important. Also fixed number of decimals to 2 for all lengths 8m becomes 8.00m 8.5 now 8.50. In both beams and table. Edited January 17 by BIGAL 1 Quote
A Tabasi Posted January 31 Author Posted January 31 (edited) Hi Mr Bigal thanks a lot for your assistance. I wonder if you found the time for solving my problem. I would appreciate your help. Edited January 31 by A Tabasi Quote
BIGAL Posted January 31 Posted January 31 I have been on holidays but will try to get back on to it. Quote
BIGAL Posted February 5 Posted February 5 Please try this and check carefully that it is correct. Run on a small number of reo bars, increase during checking. Note in sample dwg there are problems like L8.05m which should be L=8.05, I think I fixed like 5. ReoBarcount2.lsp Quote
A Tabasi Posted February 11 Author Posted February 11 (edited) it's wonderful, thanks a lot man. you do big help me. Now I'm so happy and I appreciate your kindness. so, for the last question, how do select a specific beam in the drawing for the numbering bar? For example; I want to select a couple of beams from all the beams in my drawing so that naming is done only for them. Edited February 11 by A Tabasi Quote
Recommended Posts
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.