# Sheet Metal BOM to Material Demand Python Script Generator

> Source: https://netray.co/tools/sheet-metal-bom-to-material-demand-python-script-generator
> Publisher: Netray (netray.co), AI and integration engineering for ERP and manufacturing systems.
> Section: Free Tools

## Short answer

Generates a ready-to-run Python script that totals blank weight and estimated sheet count per material and thickness from an exported part list.

## Category

developer

## Industry

Sheet Metal Fabrication

## Audience

- Fabrication engineer
- Production planner
- ERP analyst

## Tool

**Kind:** template

**Output:** code

**Language:** python

**Fields:**

#### Input CSV file

**Key:** csv_in

**Type:** text

**Default:** parts.csv

**Help:** Columns expected: part, material, thickness_mm, qty, blank_len_mm, blank_wid_mm

#### Output CSV file

**Key:** csv_out

**Type:** text

**Default:** material_demand.csv

#### Sheet length (mm)

**Key:** sheet_len

**Type:** number

**Default:** 3000

#### Sheet width (mm)

**Key:** sheet_wid

**Type:** number

**Default:** 1500

#### Expected nesting utilization (0 to 1)

**Key:** util

**Type:** number

**Default:** 0.78

**Help:** Realistic shop averages are often 0.70 to 0.85 depending on part mix.

#### Mild steel density (kg/m3)

**Key:** steel_density

**Type:** number

**Default:** 7850

**Blocks:**

#### material_demand.py

**Body:** import csv
import math
from collections import defaultdict

IN_FILE = '{{csv_in}}'
OUT_FILE = '{{csv_out}}'
SHEET_AREA_M2 = ({{sheet_len}} / 1000.0) * ({{sheet_wid}} / 1000.0)
UTILIZATION = {{util}}

# Density in kg/m3. Add the materials your shop buys.
DENSITY = {
    'MS': {{steel_density}},
    '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)

**Body:** 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

**Notes:** 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.

## Content

**Intro:** 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.

**Sections:**

#### How to use the script

**Body:** 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.

**Bullets:**

- 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

**Body:** 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

**Body:** 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

**Body:** 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.

**Cta:** If you would rather run this directly against your ERP BOMs and open orders, we can build a read-only version for your system.

**Faq:**

#### Does this replace nesting software?

**Answer:** 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?

**Answer:** 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?

**Answer:** 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?

**Answer:** 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.

## Search terms

sheet metal material requirements python, bom to sheet count script, nesting material demand estimate, csv sheet metal weight script, python sheet utilization estimate, sheet metal mrp script, export bom sheet metal csv, sheet metal raw material planning

---
Talk to an engineer: https://netray.co/contact?intent=erp_ai | Machine catalog: https://netray.co/agent/catalog.json
