In another thread a few months ago, Zolko suggested that BOM creation functionality would be a good place to do some hacking on the Asm4 workbench. I’ve had some time to prototype an implementation, and I’d like feedback/suggestions for further features.
Here’s what I have so far:
Assembly4 currently has a GUI command to assign metadata to parts using properties, that get stored under the ‘PartInfo’ group. The command is only partially implemented, so I did some work it to make it more usable

note that in the above screenshot, only one of the properties is able to be deleted. I’ve added a new property to the ‘Parameters’ group of the Model object, that enforces some required Metadata fields.

this list of field can be blanked out to give the user complete free-form control over the metadata that is added to parts.
Now, on to the actual BOM creation bit
I put the code in a seperate file (makeBomSheetCmd.py) for now, as it seemed like a better choice than appending to the existing makeBomCmd.py, which functions very differently to my code.
As the name implies, this command creates a standard FreeCAD spreadsheet. Here’s an example of what it produces:

Note the rightmost column, misc. info. The best part about this prototype is that it builds the spreadsheet based on the metadata that is actually available in the parts of the assembly, as opposed to just filling in a predetermined set of fields
# properties that have assigned values for most of the parts (we set an
# arbitrary minimum of 50% for now) will get their own column in the
# spreadsheet. properties that are only assigned to a few of the parts get
# compressed into a single column at the end
# at least X% of parts must have a property for it to get its own BOM column
minDataCommonality = 0.5
keydump = [i for sl in list(map(lambda x: x.keys(),datablock)) for i in sl]
keysCount = collections.Counter(keydump)
commonKeys = []
for key,ct in keysCount.items():
if ct/len(PartsCount) >= minDataCommonality:
commonKeys.append(key)
commonKeys.sort(key=sortf)
sheetdata.append(commonKeys+["Misc. Info"])
for pdct in datablock:
row = [""]*len(sheetdata[1])
misc = ""
for key,val in pdct.items():
if key not in commonKeys:
misc += f"{key}: {val}, "
else:
for i,x in enumerate(commonKeys):
if key == x:
row[i] = val # this whole block is hacky ATM. fix it!
row[-1] = misc
Fields that exist in a set ratio of parts get their own column, while fields that are only set in a few parts get compacted into one cell. This way, you don’t have to worry about your spreadsheet becoming many columns wide if you assign some specific fields to only a couple parts.
Some more notes:
- The spreadsheet is automatically placed in a ‘Metadata’ group, which works like the ‘Parts’ group that parts of the Asm4 model are placed in by default. For now, I just wanted a more organized feeling place to put the spreadsheet.
- My fork of the repo also has a prototype of a command that auto-generates a techdraw drawing of the entire assembly. I’m sort of thinking ahead to a point where we have the tools to generate multiple ‘metadata’ things about a model, such as dwgs, BOM, materials cut-lists, etc.
- further functionality to generate a fasteners list is already planned. Should be just a simplified subset of the already developed BOM code
At this point, I am looking for general feedback and ideas as to what community members would like to see in Asm4 BOM functionality. If you have suggestions or examples of nicely formatted BOM sheets I can take style inspiration from, send a reply. You can test out the code if you like, though it’s still rough around the edges:
https://github.com/alexneufeld/FreeCAD_Assembly4/tree/development





