Sheet Metal BOM to Material Demand Python Script Generator
This generator writes a small Python script that turns an exported part list into raw material demand by material and thickness. It gives a planner a fast sheet count and weight before the formal nesting run.
Fill in
Columns expected: part, material, thickness_mm, qty, blank_len_mm, blank_wid_mm
Realistic shop averages are often 0.70 to 0.85 depending on part mix.
material_demand.py
import csv
import math
from collections import defaultdict
IN_FILE = 'parts.csv'
OUT_FILE = 'material_demand.csv'
SHEET_AREA_M2 = (3000 / 1000.0) * (1500 / 1000.0)
UTILIZATION = 0.78
# Density in kg/m3. Add the materials your shop buys.
DENSITY = {
'MS': 7850,
'SS304': 8000,
'AL5052': 2680,
'AL6061': 2700,
}
totals = defaultdict(lambda: {'area_m2': 0.0, 'weight_kg': 0.0, 'pieces': 0})
with open(IN_FILE, newline='') as f:
for row in csv.DictReader(f):
mat = row['material'].strip()
thk = float(row['thickness_mm'])
qty = int(row['qty'])
area = (float(row['blank_len_mm']) / 1000.0) * (float(row['blank_wid_mm']) / 1000.0) * qty
dens = DENSITY.get(mat)
if dens is None:
raise SystemExit('Unknown material: ' + mat + ' (add it to DENSITY)')
key = (mat, thk)
totals[key]['area_m2'] += area
totals[key]['weight_kg'] += area * (thk / 1000.0) * dens
totals[key]['pieces'] += qty
with open(OUT_FILE, 'w', newline='') as f:
w = csv.writer(f)
w.writerow(['material', 'thickness_mm', 'pieces', 'blank_area_m2', 'blank_weight_kg', 'sheets_needed'])
for (mat, thk), t in sorted(totals.items()):
sheets = math.ceil(t['area_m2'] / (SHEET_AREA_M2 * UTILIZATION))
w.writerow([mat, thk, t['pieces'], round(t['area_m2'], 3), round(t['weight_kg'], 1), sheets])
print('Wrote ' + OUT_FILE)Sample input (parts.csv)
part,material,thickness_mm,qty,blank_len_mm,blank_wid_mm BRK-100,MS,3,120,210,95 CVR-210,AL5052,2,40,600,420 PNL-330,SS304,1.5,25,880,540
Uses the bounding box of each blank, so it overstates area for non-rectangular parts. Replace it with true flat pattern area if your CAD export has it. Nesting utilization is an assumption, not a nest result. Requires Python 3 and no extra packages.
Run material demand from live ERP data
Optional: a read-only version of this report connected to your ERP.
Optional. The tool and every export work without this. No spam.
How to use the script
Export your part list to CSV with the six columns shown, fill in the fields on this page, and copy the generated script into a file such as material_demand.py. Run it with Python 3 from the folder holding the CSV. The output file lists, for each material and thickness, the piece count, total blank area, blank weight and an estimated sheet count. Paste the result into Excel or an ERP purchase requisition.
- Keep material codes consistent with the DENSITY table in the script.
- Run it per job or per week of released work.
- Add a column for coating weight if freight is weight-driven.
The method behind the numbers
Blank area is length times width times quantity. Weight is area times thickness times density. Sheet count divides total blank area by the usable area per sheet, which is the sheet area multiplied by an assumed nesting utilization, then rounds up. It is an estimate for early purchasing and quoting, because real utilization depends on part shapes, grain constraints, kerf, lead-in and the remnant policy of the shop.
Improving accuracy
Replace bounding box dimensions with the actual flat pattern area from your CAD or CAM export. Track utilization from completed nests and use the real average per material family rather than a single number. For repeat orders, store the nest yield by part family. Also decide how remnants are handled, since reusable offcuts raise effective yield while unusable skeletons are scrap.
Common mistakes
Mixing thicknesses under one material code, forgetting that stainless and aluminum have different densities, and assuming 100 percent utilization are the usual errors. Another trap is forgetting that parts with grain direction or brushed finish restrict rotation in the nest and lower yield.
Frequently Asked Questions
Does this replace nesting software?
No. It gives a planning estimate before nesting. Final sheet usage comes from the nest result in your CAM package. Use the script for early purchasing, quoting and sanity checks.
What nesting utilization should I use?
Many shops see between roughly 70 and 85 percent, depending on part mix. Use the real average from your recent nests for the material in question, rather than a generic figure.
Can I add more materials?
Yes. Add entries to the DENSITY dictionary with the same code you use in the CSV. Use nominal densities in kilograms per cubic metre.
Does the script send data anywhere?
No. It reads and writes local files only and uses the Python standard library. This page also runs in your browser, so nothing is uploaded.
If you would rather run this directly against your ERP BOMs and open orders, we can build a read-only version for your system.
Related Tools
Sheet Metal Density and Weight per Area Reference
Density and weight per area per millimetre of thickness for steel, stainless, aluminum, copper, brass and titanium sheet.
Developer ToolsSheet Metal Job Cost Rollup SQL Query Generator
Builds a job cost rollup query over generic job, operation and material tables, with your table and column names filled in.
Supply Chain & InventorySheet Metal Fabrication RFQ Request Template
A fill-in RFQ document for sending a sheet metal part package to a fabricator, with all the details needed for an accurate quote.
Engineering & PLMSheet Metal DFM Design Review Checklist
A pre-release checklist for sheet metal parts covering cutting, bending, hardware, tolerance and finishing issues that cause rework and quote changes.
More Developer Tools tools
See all- SAP Sales Order ABAP SELECT Generator (VBAK, VBAP, VBFA)
- SAP Sales Order Create BAPI ABAP Generator (BAPI_SALESORDER_CREATEFROMDAT2)
- SAP ABAP Open Items SELECT Generator
- SAP ACDOCA SQL Query Generator
- SAP QM Inspection Lot ABAP SELECT Generator
- SAP Quality Notification Pareto SQL Query Generator
- SAP QM Usage Decision BAPI Skeleton
- ABAP Custom Exception Class Generator
- ABAP Unit Test Class Generator