[Ext] Selection 2 Bill of Materials (supporting recursive group instances)

THE REPOSITORY IS THE MOST UP TO DATE SOURCE OF INFORMATION!
WARNING: ALL BELOW MAY BE TECHNICAL, DISCUSSION OR OUTDATED!

Example BoM (took only 5…10 minutes to generate due to the new cache of recursive assembly dimension calculations)

Hey blenderartists,
I wish to share a new addon with you. Not sure if someone already untertook efforts in that area, but as I had certain feature wishes I just decided to quickly throw selection2BoM together. A goal is to not require any extra setup, data or input - in my opinion a BoM should be generated directly out of the objects’ names and materials. Another important feature I wished was to decide whether group instances act as real individual complete independant standalone (mechanical) parts or if they should be resolved to the objects contained therein. And here we go - you get Selection2BoM!

^ Check Github for releases.
Gotcha note to addon developers: python addons are not loadable if they contain a point (.) in the filename, e.g. 2.xy.py won’t work.

Where to find the settings?
Once installed, you should find the settings under Tool-shelf (T) of the 3DView above the last operator panel or in newer blender versions (2.7+) within the Toolshelf -> Misc.


Possible improvements:

  • The dimensions eventually should be calculated differently? (tbd)

Features:

  • Accurate item/part counts: Every object dimension and object name and object material triple is listed once, and how often it occurred. If a parent group instance (assembly) has some transformation then this is inherited and results in a new BoM entry. This allows for very advanced and non-redundant modelling.
  • Different modi: Group instances (read: assemblies) can be counted as complete standalone part on its own - or they can be resolved to the objects contained in the group.
  • Use atom: in the group instance object’s name to prevent decomposition.
  • Resolving groups to objects works without changing anything in the scene (utilizing complex recursive duplication algorithm).
  • Resolving group material from group’s object functional.
  • Auto-selection working. Prior to the Beta release a selection had to be made manually. Otherwise the addon crashed. Now this is solved.
  • Dimensions of group instances now are automatically resolved from all underlaying objects.
  • Units now are included in the bill of materials.
  • Unit settings of the scene are now taken into account when calculating the dimensions.
  • Some efforts for getting a better structure in the Bill of Materials text files without hopefully loosing too much speed.
  • Objects properly inherit all transformations (e.g. different scale of a group instance than another instance of the same group).
  • Hybrid mode for listing all assemblies and how often they are used. (next to the overall part counts)
  • Added support for recursive assemblies (group instances within group instance(s) which is within another group (instance), and so on).
  • Fixed some bugs like randomly failing to create the Bill of materials.
  • Now no longer just writes all files into the home directory. Instead it writes it to the directory that contains the .blend that is open in blender.
  • Hybrid mode shows part counts for each part of each unique assembly. Useful for knowing how many parts (e.g. screws) that assembly needs.
  • Scene and active object determine the BoM-txt-filename.
  • Parts are resolved to underlaying (redundant) data. (e.g. group instances are counted!, identical/linked objects also get only one entry).
  • That is: objects sharing the objectdata result in different parts if the scale is different.
  • Automatically guessing what to select if no selection is made prior to invoking this selection2BoM addon.
  • Support for atomar assemblies.
  • Hybrid mode: global parts list no longer lists assemblies, also empty assemblies no longer show in the assembly listing in the BoM. And the assembly listing now shows proper assembly occurrence counts.
  • Finally proper alignment for all entries (fixes a multitude of issues).
  • Support for optional parts/assemblies. ->Example.

It may finally be useful for what we wanted it to do. The output of the addon now answers the following questions:

  • Which parts were used?
  • How many parts were used?
  • How were the parts grouped (assemblies)?
  • Are the optional parts? How many?
  • Of what (approximate) dimensions are the parts?

Selected objects only?

  • Either Selection -> Bill of Materials.
  • Or all objects in scene besides hidden ones -> Bill of Materials.

How to install:

  • Get it via Git or, if you don’t have Git, use this: https://github.com/faerietree/blende...n2bom/releases

  • Unzip the attachment from above (Releases).

  • In blender open addons menu. CTRL+ALT+U

  • Install addon.
    (Or put it either in ~/.config/blender/<version>/scripts/addons/ or <where-blender-installed-directory>/<version>/scripts/addons/ .)

  • Either select objects to include or hide objects to exclude from the BoM.

  • Hit the button ‘Selection2BoM’ in the toolshelf (3DView + T).

  • Look for the BoM-<active-object>.txt in the filesystem.

  • Examine if everything is fine. If not start blender via the terminal/command line(cmd), reexecute the script. Copy the output in this thread or describe what went wrong.


Limitations
No efforts so far to parse a website of a supplier like McMaster, DigiKey, Mouser, RadioSupply, Granger, … you know all those … for real parts. A lot of work will be to rescale the parts that are not available in certain sizes (bearings, …), because this would require scaling other parts (e.g. bearing fittings) of the drawing too. And as people may wish to create custom parts it would be a good idea to at least make this optional.

Future:
In the longer term I plan to create a full-fledged KiCAD integration. The genious drawing capabilities of Blender are perfect for simplifying electronic design where fiddling in der GUIs is horrible and ineffective. Why shouldn’t all algorithms required for electronic circuit design work in blender too? (perhaps I’m dreaming …)

I think ElectronicsCAD tools like KiCAD or EAGLE are bulky - why do we need redundant extra symbols for each footprint? Why not have non-redundant footprints which specify a list of all parts/symbols they exist for and assign/choose them from a drop-down list with preview and measurements on the fly directly in the schematic editor. Then a decent auto-router and there we had it if we only had it.

The next addon planned is an improvement of the render2print extension with an option to print in real world scale.

Thank you very much for making blender what it is … brilliant.
Hope this add-on helps someone and we can improve it.

Jan R.B.-Wein, formerly known as Radagast (wonder why?:mrgreen:)
Fellow of green open source technology and ecology,
Knight of blender,
Mage of RepRap - let’s join efforts! blue planet united!

Attachments


New features in Beta:

  • Item/Part count now calculated correctly.
  • Group instances as complete standalone part on its own finally is possible.
  • Resolving groups to objects now working.
  • Resolving group material from group’s object functional.
  • Auto-selection working. Prior to that (in the Alpha release) a selection HAD to be made. Otherwise the addon crashed. Now this is solved.
  • Dimensions of group instances now are automatically resolved from all underlaying objects.
  • Units now are included in the bill of materials.
  • Unit settings of the scene are now taken into account when calculating the dimensions.
  • Some efforts for getting a better structure in the Bill of Materials text files without hopefully loosing too much speed.

Another release:

  • Now the precision of dimensions can be set in the tool shelf [T] ‘Selection to BoM’ panel.

You forgot about the “What It Does” or “What It’s For” section in your post.

Ah yes I get the point , now I’ve written so much and still not mentioned that?

Usually it’s hard to count all the objects you have used in a (e.g. mechanical) model. But now you want to buy the parts and there is no other way than counting those objects that are equal to get a parts count.

And here the addon comes in and says, hej, what about enjoying the sun, I will do it for you - it takes me two seconds. :eyebrowlift:

Updated for blender 2.73:

  • Accurate part counts.

  • Added support for recursive assemblies (group instances within group instance(s) which is within another group (instance), and so on).

  • Fixed some bugs like randomly failing to create the Bill of materials.

  • Now no longer just writes all files into the home directory. Instead it writes it to the directory that contains the .blend that is open in blender.

  • Objects properly inherit all transformations (e.g. different scale of a group instance than another instance of the same group).

  • Added Hybrid mode. (Allows to show all assemblies used (and how often it has been used) in the BoM.)

  • Just added that the part counts for each part of each unique assembly also is shown. Useful for knowing how many parts (e.g. screws) that assembly needs. (not yet pushed to the repository)

Fixed segfaults.
Fixed addon only working properly on first execution after blender start.

Added and pushed the enhanced hybrid mode (part-listing per assembly additionally to the total part counts). Useful for assembly to know which coherent part (assembly) requires which parts.

Also fixed the assembly listing in the generated BoM showing the total parts and their counts instead of the per assembly counts.

The group instances dimensions are resolved from all the group’s objects’ unioned dimensions.

Other from that, this addon is finally completely production-ready. Can’t think of any functionality that’s missing other than printing an ASCII art representation of the parts themselves. Perhaps calculating the mass, but that depends on the material. Thus that’s an optional feature. And not sure how it could be useful (of course for physical simulation/stress analysis it is! But for a Bill of materials?).

To get the recursive assembly decomposition algorithm to work was a major milestone towards the selection2blueprint and selection2assemblymanual addons.

If you don’t have Git, use this to get the addon: https://github.com/faerietree/blender_addon__selection2bom/releases

Fixed a huge bug: Objects located on invisible layers of a scene were treated as if they’d been explicitely hidden.

Now only explicitely hidden (e.g. shortcut H) objects are not listed in the Bill of materials. This fixes a plethora of issues like empty assemblies or wrong part counts …

Example BoM (took 1…2 hours to generate due to recursive assembly dimension calculation):

Fixed atomar objects being treated as non-atomar. Just add ‘atom’ to the (group instance) object’s name and it’ll not be resolved. Useful for Mode 2 and 3 (Hybrid).

FaerieTree thank you for your work. This addon is a must have for me working as a builder. I still cannot get this thing to work.
I get an error message about permission denied BoM scene text. Am I doing something wrong?

May be a filesystem permission issue. Can you launch blender from the terminal (CTRL+ALT+T) via /path/blender-files/blender ? If possible please send me the error log that is printed to the console.

Update

  • Massively improved hybrid mode: global parts list no longer lists assemblies, also empty assemblies no longer show in the assembly listing in the BoM. And the assembly listing now shows proper assembly occurrence counts.

  • Finally proper alignment for all entries (fixes a multitude of issues).

  • Support for optional parts/assemblies. ->Example.

It may finally be useful for what we wanted it to do. The output of the addon now answers the following questions:

  • Which parts were used?
  • How many parts were used?
  • How were the parts grouped (assemblies)?
  • Are the optional parts? How many?
  • Of what (approximate) dimensions are the parts?

Thanks Faerietree it is working fine now. I am now using your latest update and now it works. I must save my blender file first and it works great. Thank you.

Faerietree… I am trying out your addon and it does help in getting a materials list of what I have in the scene. My problem is
the measurements of the individual parts are wrong. for example I have 10 pieces of lumber 2x4x10’ but it gives me different
dimensions [3.1ft x 0.1ft x 0.0ft] Thanks in advance

Great it at least works. Will add a workaround for the not-yet-having-saved-the-.blend file problem. Thanks for finding and reporting this issue.

hm, strange, the measurements work for me in metric settings. Will check if the scale length (scene unit settings) are somehow not yet handling correctly.

Metric units example output: BOM for pluggable green energy waterwheel.

Turns out, that in Hybrid mode the generated BOM also is useful for finding duplicated and empty assemblies/group instances.

Thanks for reporting the not-yet-saved filepath issue. That’s mitigated in the newest version.

The units now also should appear correctly. Thanks for pointing this out. Thanks to macouno too for showing how to handle different unit systems in his caliper measurement addon.

Does it work for you now?

Hello. Nice to see a BOM generator for Blender. I just need to use this for Furniture fabrication. For this purpose I need an option to tell what is the wood grain for every sheet component and another option to define EdgeBanding for every individual edge of components. Also a labelling generator for every component containing some part description and which edges need to have EdgeBanding, will be good. I can provide further feedback if needed.

Faerietree dimensions are now showing up correctly in the imperial system Big thanks… great addon!

Glad if it’s helpful.

Coincidentally a row for information (e.g. part number, URI, …) has been added. Just use the datablock’s name for it (in the properties’ mesh/curve tab). Not felt happy with maintaining another data input field if the name of the datablock (mesh/curve) was unused anyway. So just use that for providing more information.

Other than that I’m not familiar of how to add information on an per object level and yet keep it user-editable.

But don’t be sad, comrades, to partly compensate I just coded caching of assembly dimensions which is a significant speedup (if you use group instances heavily to ease modification and reusability of the engineering model).

Also fixed precision of 0 not taken into account properly and fixed the broken heading alignment.

Oh, and it should fit on A4 now on printout. The line break just shocked me when I printed the waterwheel BOM lately …

For your information, there is also quantitiesbill.py by Yorik van Havre (who now is freecad lead developer). Among the other of his scripts.