Get a count of component occurrences in an assembly?

Programming and macros
User avatar
mike miller
Posts: 878
Joined: Fri Mar 12, 2021 3:38 pm
Answers: 7
Location: Michigan
x 1070
x 1231
Contact:

Get a count of component occurrences in an assembly?

Unread post by mike miller »

Is there any way to get a total count of a component, including inside subassemblies? Like an atomic BOM would do. (don't say that sentence out loud..)

We would like to have that value returned for use in a naming string if possible.

@gupta9665
@artem
@josh
@Rob
by artem » Thu Dec 23, 2021 4:25 pm
BOM+ (https://cadplus.xarial.com/bom/) has an option to generate flat BOM. Here is the video demonstration (2:10 mark about the flat BOM):

And here is the macro to write the qty to the custom property so you can then use it for naming:
Go to full post
He that finds his life will lose it, and he who loses his life for [Christ's] sake will find it. Matt. 10:39
DLZ_SWX_User
Posts: 48
Joined: Mon Dec 20, 2021 1:40 pm
Answers: 0
Location: Thumb Area of Michigan, USA
x 175
x 26

Re: Get a count of component occurrences in an assembly?

Unread post by DLZ_SWX_User »

Thanks @mike miller ,

This is what I was trying to get to happen in the thread: :arrow:
https://www.cadforum.net/viewtopic.php?p=9594#p9594
artem
Posts: 26
Joined: Thu Mar 18, 2021 1:31 pm
Answers: 3
x 9
x 74

Re: Get a count of component occurrences in an assembly?

Unread post by artem »

BOM+ (https://cadplus.xarial.com/bom/) has an option to generate flat BOM. Here is the video demonstration (2:10 mark about the flat BOM):

And here is the macro to write the qty to the custom property so you can then use it for naming:
Thanks,
Artem
xarial.com - making your CAD better
codestack.net - SOLIDWORKS API macros and tutorials
User avatar
gupta9665
Posts: 405
Joined: Thu Mar 11, 2021 10:20 am
Answers: 25
Location: India
x 426
x 445

Re: Get a count of component occurrences in an assembly?

Unread post by gupta9665 »

You can also look at the codes posted here https://forum.solidworks.com/thread/50568
Deepak Gupta
SOLIDWORKS Consultant/Blogger
User avatar
mike miller
Posts: 878
Joined: Fri Mar 12, 2021 3:38 pm
Answers: 7
Location: Michigan
x 1070
x 1231
Contact:

Re: Get a count of component occurrences in an assembly?

Unread post by mike miller »

artem wrote: Thu Dec 23, 2021 4:25 pm BOM+ (https://cadplus.xarial.com/bom/) has an option to generate flat BOM. Here is the video demonstration (2:10 mark about the flat BOM):

And here is the macro to write the qty to the custom property so you can then use it for naming:
Thanks @artem. I was hoping I could get a count as easily as I can get a custom property. Oh well, this works fine even if it's an extra step.
He that finds his life will lose it, and he who loses his life for [Christ's] sake will find it. Matt. 10:39
starshiphalo2333
Posts: 9
Joined: Fri Sep 30, 2022 11:49 am
Answers: 0
x 1

Re: Get a count of component occurrences in an assembly?

Unread post by starshiphalo2333 »

Does anyone know a way to do this without BOM+ ? BOM+ is a paid add-in, the BOM tools require the 500 AUD license.

I basically one a flat BOM with total quantities of each component (SLDASM and SLDPRT)

BOM Example:
1234B - QTY 1
-----1235C - QTY 5
----------45332 - QTY 2
----------32233 - QTY 1
----------12112 - QTY 5

Desired BOM:
1234B - QTY 1
1235C - QTY 5
45332 - QTY 10
32233 - QTY 5
12112 - QTY 25
User avatar
josh
Posts: 293
Joined: Thu Mar 11, 2021 1:05 pm
Answers: 16
x 22
x 500

Re: Get a count of component occurrences in an assembly?

Unread post by josh »

Place a single "dummy" empty part in each assembly/subassembly. Give it the custom properties that you want to show in the BOM for that assembly/subassembly. Make a "Parts Only" BOM instead of indented.
starshiphalo2333
Posts: 9
Joined: Fri Sep 30, 2022 11:49 am
Answers: 0
x 1

Re: Get a count of component occurrences in an assembly?

Unread post by starshiphalo2333 »

josh wrote: Wed Jan 04, 2023 6:05 pm Place a single "dummy" empty part in each assembly/subassembly. Give it the custom properties that you want to show in the BOM for that assembly/subassembly. Make a "Parts Only" BOM instead of indented.
Ah, that would work - nice workaround. Unfortunately that's not a great solution for us, we have thousands of assemblies from over the years (been using SW since 2000). We would have to manually add this dummy part to all of those assemblies - and any new assembly going forward.
User avatar
bnemec
Posts: 1941
Joined: Tue Mar 09, 2021 9:22 am
Answers: 10
Location: Wisconsin USA
x 2540
x 1398

Re: Get a count of component occurrences in an assembly?

Unread post by bnemec »

Sounds like $500 is a good deal for a turn-key solution that does what you need. I've tried to help where I work automate things (mostly because I'm terrible at repeating a mundane process identically over and over). Wrote a BOM extractor for Solid Edge files, then updated it to pull file refs from PDM. What you're asking for is completely doable. Now I don't have time for automation/API projects anymore as they have me doing other stuff. They've tried hiring contract API labor and are flabbergasted at the hourly rate then looked elsewhere and got similar numbers. I kinda told them, "Yeah, that's the going rate".
User avatar
josh
Posts: 293
Joined: Thu Mar 11, 2021 1:05 pm
Answers: 16
x 22
x 500

Re: Get a count of component occurrences in an assembly?

Unread post by josh »

starshiphalo2333 wrote: Wed Jan 04, 2023 6:36 pm Ah, that would work - nice workaround. Unfortunately that's not a great solution for us, we have thousands of assemblies from over the years (been using SW since 2000). We would have to manually add this dummy part to all of those assemblies - and any new assembly going forward.
What format do you need? Are you just looking for a report/knowledge, or are you wanting an actual SolidWorks BOM on a drawing? The "Assembly Visualization" tool will generate the flat total info you're looking for.
User avatar
mattpeneguy
Posts: 1386
Joined: Tue Mar 09, 2021 11:14 am
Answers: 4
x 2489
x 1899

Re: Get a count of component occurrences in an assembly?

Unread post by mattpeneguy »

josh wrote: Thu Jan 05, 2023 5:17 pm What format do you need? Are you just looking for a report/knowledge, or are you wanting an actual SolidWorks BOM on a drawing? The "Assembly Visualization" tool will generate the flat total info you're looking for.
I forgot about that tool because I used it so long ago. It also lets you export to Excel. I remember using it to spit out components and weights because our structural people were trying to determine a center of gravity.
Post Reply