Author Topic: How to statistics the total number of parts?  (Read 19474 times)

0 Members and 1 Guest are viewing this topic.

xianaihua

  • Guest
How to statistics the total number of parts?
« on: January 05, 2010, 07:23:28 AM »
Hello all,
I want to assemble a body of statistics for each sub-assembly and parts of the total numbers,
Their assembly relation is shown below.


The number behind each piece, but the pieces in the last one in a number of sub-assembly.

According to bom of each dwg,I constructed the following list:
("sub-assembly1-1" "assembly" 2)
("sub-assembly1-2" "assembly" 3)
("sub-assembly1-3" "assembly" 2)
("pat1-1" "assembly" 3)
("pat1-2" "assembly" 2)
("pat1-3" "assembly" 1)
("sub-assembly2-1" "sub-assembly1-1" 3)
("sub-assembly2-2" "sub-assembly1-1" 3)
("sub-assembly2-3" "sub-assembly1-1" 2)
("pat2-1" "sub-assembly1-1" 3)
("pat2-2" "sub-assembly1-1" 2)
("pat1-3" "sub-assembly1-1" 1)
("pat3-1" "sub-assembly2-1" 3)
("pat3-2" "sub-assembly2-1" 2)
("pat2-1" "sub-assembly2-1" 1)

Example:total numbers of "pat3-1"=3X3X2X1
That,numbers of "pat3-1" in the "sub-assembly2-1" *  numbers of "sub-assembly2-1" in the "sub-assembly1-1" * numbers of "sub-assembly1-1" in the "assembly" *  numbers of "assembly"(By default, the top-level assembly's number is one)
I want to have a recursive algorithm, was the total number of new list
("sub-assembly1-1" "assembly" 2 2);2X1
("sub-assembly1-2" "assembly" 3 3);3X1
("sub-assembly1-3" "assembly" 2 2);2X1
("pat1-1" "assembly" 3 3);3X1
("pat1-2" "assembly" 2 2);2X1
("pat1-3" "assembly" 1 1);1X1
("sub-assembly2-1" "sub-assembly1-1" 3 6);3X2X1
("sub-assembly2-2" "sub-assembly1-1" 3 6);3X2X1
("sub-assembly2-3" "sub-assembly1-1" 2 4);2X2X1
("pat2-1" "sub-assembly1-1" 3 6);3X2X1
("pat2-2" "sub-assembly1-1" 2 4);2X2X1
("pat1-3" "sub-assembly1-1" 1 2);1X2X1
("pat3-1" "sub-assembly2-1" 3 18);3X3X2X1
("pat3-2" "sub-assembly2-1" 2 12);2X3X2X1
("pat2-1" "sub-assembly2-1" 1 6);1X3X2X1

All friends, how to do this recursively?

First of all, thanks !



« Last Edit: January 05, 2010, 06:28:24 PM by xianaihua »

xianaihua

  • Guest
Re: How to statistics the total number of parts?
« Reply #1 on: January 05, 2010, 09:56:54 PM »
Hi all..

Anyone have an idea on how to get tol numbers of parts?

thanks.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: How to statistics the total number of parts?
« Reply #2 on: January 05, 2010, 10:25:00 PM »
Maybe tomorrow, I'm done for the day. :-)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

xianaihua

  • Guest
Re: How to statistics the total number of parts?
« Reply #3 on: January 06, 2010, 06:56:47 PM »
I look forward to the guidance of CAB, and other masters! :-D

T.Willey

  • Needs a day job
  • Posts: 5251
Re: How to statistics the total number of parts?
« Reply #4 on: January 06, 2010, 07:28:56 PM »
Here is a start.  You can do the recursion changes to make it do what you want exactly.

Code: [Select]
(defun ShowBlockNesting ( blkName blkCol / tempList tempName NestingList)
   
    (if (not (vl-catch-all-error-p (setq BlkObj (vl-catch-all-apply 'vla-Item (list blkCol blkName)))))
        (vlax-for obj BlkObj
            (if (= (vla-get-ObjectName obj) "AcDbBlockReference")
                (if (setq tempList (assoc (setq tempName (vla-get-Name obj)) NestingList))
                    (setq NestingList (subst (cons tempName (1+ (cdr tempList))) tempList NestingList))
                    (setq NestingList (cons (cons tempName 1) NestingList))
                )
            )
        )
    )
    (cons blkName NestingList)
)

(defun c:Test ()
    (showblocknesting (cdr (assoc 2 (entget (car (entsel))))) (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))))
)
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

adalea03

  • Guest
Re: How to statistics the total number of parts?
« Reply #5 on: January 06, 2010, 08:13:09 PM »
No master here, but I would block everything (with attributes).
SSget all the parts, and drill through list(s) , counting as you go.
Sound so simmple, doesn't it?

i.e.
Block A contains 4 distint parts .
Get/count all instances of block A.
(List "Block A" integer-blockcountA  ("subpart1" (* integer-blockcountA qty-subpart1))  ("subpart2" (* integer-blockcountA qty-subpart2)))
                                                        ("subpart3" (* integer-blockcountA qty-subpart3)))  ("subpart4" (* integer-blockcountA) qty-subpart4)))
Block B contains 12 distint parts .
(List "Block B" integer-blockcountB  ("subpart1" (* integer-blockcountB qty-subpart1))   ...

There may be a lot  of "hard coding" necessary to achieve your goal,
but if your needs are specific to your discipline ,
just "Get 'er done", any 'ole way you can.

AA






adalea03

  • Guest
Re: How to statistics the total number of parts?
« Reply #6 on: January 06, 2010, 08:25:58 PM »
Better yet, follow T.Wiley.

xianaihua

  • Guest
Re: How to statistics the total number of parts?
« Reply #7 on: January 07, 2010, 06:10:08 AM »
thanks,

Sorry, my English is poor, not explained clearly.

Now, regardless of anything else, we can reduce the problem only to the list of recursive processing.

In accordance with the above requirements, how the recursive computation of the list? Please express anyone's idea and suggestions!

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: How to statistics the total number of parts?
« Reply #8 on: January 07, 2010, 09:21:19 AM »
Why does it have to be recursive? Is this a homework assignment?
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

xianaihua

  • Guest
Re: How to statistics the total number of parts?
« Reply #9 on: January 07, 2010, 10:10:47 AM »
hi,CAB!

Of course, do not use the recursive method can also be!Doing mechanical design, we often have statistical part quantity.Bom assembly drawings of each style is shown below
« Last Edit: January 07, 2010, 10:27:54 AM by xianaihua »

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: How to statistics the total number of parts?
« Reply #10 on: January 07, 2010, 11:33:00 AM »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: How to statistics the total number of parts?
« Reply #11 on: January 07, 2010, 11:33:35 AM »
Why does it have to be recursive? Is this a homework assignment?


I think because I said recursive, as that lends itself to these type of situations.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: How to statistics the total number of parts?
« Reply #12 on: January 07, 2010, 12:05:14 PM »
Thanks Tim, but at the end of the Op's first post:
Quote
All friends, how to do this recursively?

From futher postings it is obviously not Homework, from school anyway.  :-)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: How to statistics the total number of parts?
« Reply #13 on: January 07, 2010, 12:12:52 PM »
You pay better attention that I do Alan, as I didn't even see that requirement.   :-D
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: How to statistics the total number of parts?
« Reply #14 on: January 07, 2010, 12:32:33 PM »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.