muthu123 Posted May 9, 2010 Posted May 9, 2010 Dear friends, Please refer the attached drawing with table. How can i convert all the part description under the column "DESCRIPTION" to a list. Then i can calculate weight and put it the Weight Column. Please help. yours, Muthu. table.dwg Quote
fixo Posted May 9, 2010 Posted May 9, 2010 Dear friends, Please refer the attached drawing with table. How can i convert all the part description under the column "DESCRIPTION" to a list. Then i can calculate weight and put it the Weight Column. Please help. yours, Muthu. What is the formula to calculate weight by description? ~'J'~ Quote
muthu123 Posted May 9, 2010 Author Posted May 9, 2010 What is the formula to calculate weight by description? ~'J'~ I have a function to calculate the wt for a given description and it will return the weight. Ex.(cal_wt_part "5X150X6500") it will return 4.875. But i have to know that where i can place this value and how can i get the row and column number of the Description cells. Yours, Muthu. Quote
fixo Posted May 9, 2010 Posted May 9, 2010 Ok, if you won't to show your secret formula so do it by yourself I'm busy today (if (setq sset (ssget "+.:S:L" '((0 . "ACAD_TABLE")))) (progn (setq atable (vlax-ename->vla-object (ssname sset 0))) (setq column 2 row 2) (while (< row 9) (setq lst(cons (vla-gettext atable row column) lst)) (setq row (1+ row)))) ) (setq lst (reverse lst)) ~'J'~ Quote
muthu123 Posted May 9, 2010 Author Posted May 9, 2010 Ok, if you won't to show your secret formula so do it by yourselfI'm busy today (if (setq sset (ssget "+.:S:L" '((0 . "ACAD_TABLE")))) (progn (setq atable (vlax-ename->vla-object (ssname sset 0))) (setq column 2 row 2) (while (< row 9) (setq lst(cons (vla-gettext atable row column) lst)) (setq row (1+ row)))) ) (setq lst (reverse lst)) ~'J'~ I thing u misunderstand me. Actually we have so many types of descrptions and standard parts and weigts.So it is a big function to calculate weight. Anyhow i will attach the files for your reference. ;;fuction is (wt_cal_single_desc sk_part sk_mark sk_part_quantity) ;; arguments sk_part - Description such as "5X150X6100", "S-CL01", "IPEA200X6500" etc... ;;sk_mark - Piecemark such as "OF-1" IF-1" "HR-1" "EP-1" etc... ;;; sk_part_quantity - aty of the qty column. Thank you so much for your reply. Your Sincerly, Muthu. TOOL.zip Quote
fixo Posted May 9, 2010 Posted May 9, 2010 I thing u misunderstand me. Actually we have so many types of descrptions and standard parts and weigts.So it is a big function to calculate weight. Anyhow i will attach the files for your reference. ;;fuction is (wt_cal_single_desc sk_part sk_mark sk_part_quantity) ;; arguments sk_part - Description such as "5X150X6100", "S-CL01", "IPEA200X6500" etc... ;;sk_mark - Piecemark such as "OF-1" IF-1" "HR-1" "EP-1" etc... ;;; sk_part_quantity - aty of the qty column. Thank you so much for your reply. Your Sincerly, Muthu. We have a Victory Day today I could help you tomorrow only ~'J'~ Quote
muthu123 Posted May 9, 2010 Author Posted May 9, 2010 We have a Victory Day today I could help you tomorrow only ~'J'~ No problem. Quote
fixo Posted May 10, 2010 Posted May 10, 2010 Unfortunatelly I can't test the code below because of my AutoCAD is crashed at all Here is just a quick and dirty that partially was written from memory (defun get_wt_by_desc (desc) (cond ((= "6X300-500X5546" desc) 104.49) ((= "10x0-95x142" desc) 1.06) ((= "10x0-80x80" desc) 0.25) ((= "5X80X180" desc) 1.70) ((= "6X150X5546" desc) 39.18) ((= "6X150X5550" desc) 39.21) ((= "16x200x652" desc) 16.38) ) ) (defun C:RECALC (/ atable column descript en ent lst row rows sset total wt) (vl-load-com) (setq sset (ssget "+.:S:N" '((0 . "ACAD_TABLE")))) (setq atable (vlax-ename->vla-object (ssname sset 0))) (vla-put-regeneratetablesuppressed atable :vlax-true) (setq column 2 row 3 total 0.0 rows (vla-get-rows atable)) (while (/= row rows) (setq descript (vlax-variant-value (vla-getvalue atable row column 0))) (if (setq wt (get_wt_by_desc descript));<--if found description (progn (setq lst (cons descript lst)) (vla-settext atable row (1+ column) (rtos wt 2 2)) (setq total (+ wt total))) ) (setq row (1+ row)) ) (setq lst (reverse lst)) (princ lst) ;; < work with lst here if you need > (setq row 0) ;;here may be the wrong part (change by yourself): (while (wcmatch (vla-gettext atable row column) "*WEIGHT SUM*" ) (setq row (1+ row)) ) (vla-settext atable row (1+ column) (rtos total 2 2)) (vla-put-regeneratetablesuppressed atable :vlax-false) (princ) ) ~'J'~ Quote
muthu123 Posted May 11, 2010 Author Posted May 11, 2010 Unfortunatelly I can't test the code belowbecause of my AutoCAD is crashed at all Here is just a quick and dirty that partially was written from memory (defun get_wt_by_desc (desc) (cond ((= "6X300-500X5546" desc) 104.49) ((= "10x0-95x142" desc) 1.06) ((= "10x0-80x80" desc) 0.25) ((= "5X80X180" desc) 1.70) ((= "6X150X5546" desc) 39.18) ((= "6X150X5550" desc) 39.21) ((= "16x200x652" desc) 16.38) ) ) (defun C:RECALC (/ atable column descript en ent lst row rows sset total wt) (vl-load-com) (setq sset (ssget "+.:S:N" '((0 . "ACAD_TABLE")))) (setq atable (vlax-ename->vla-object (ssname sset 0))) (vla-put-regeneratetablesuppressed atable :vlax-true) (setq column 2 row 3 total 0.0 rows (vla-get-rows atable)) (while (/= row rows) (setq descript (vlax-variant-value (vla-getvalue atable row column 0))) (if (setq wt (get_wt_by_desc descript));<--if found description (progn (setq lst (cons descript lst)) (vla-settext atable row (1+ column) (rtos wt 2 2)) (setq total (+ wt total))) ) (setq row (1+ row)) ) (setq lst (reverse lst)) (princ lst) ;; < work with lst here if you need > (setq row 0) ;;here may be the wrong part (change by yourself): (while (wcmatch (vla-gettext atable row column) "*WEIGHT SUM*" ) (setq row (1+ row)) ) (vla-settext atable row (1+ column) (rtos total 2 2)) (vla-put-regeneratetablesuppressed atable :vlax-false) (princ) ) ~'J'~ Thank you So much. Can you explain the selection method "+.:S:N"? And do you have any other methods? Yours Muthu. 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.