---
title: "Creating Material and Supplemental Equipment through Scripting 3.0"
id: "creating-material-and-supplemental-equipment-through-scripting-3-0"
project: "Knowledge Base"
url: "https://docs.sepasoft.com/articles/knowledge-base/creating-material-and-supplemental-equipment-through-scripting-3-0"
updated: 2026-07-23T18:08:27Z
---

# Creating Material and Supplemental Equipment through Scripting 3\.0

## Overview

The MES Management Screen can be used to create Material Classes and Definitions, however creating a large number or "on the fly" Material or Supplemental Equipment is not efficient through this interface. Two examples follow, one for a large number of Material Definitions and another for an "on the fly" Supplemental Equipment example.

For a case where a company has hundreds of materials or if the ERP system manages materials, it is likely that you will want to dynamically create materials through scripting. The code block below provides an example of a script that creates a Material Class called **LargeMatCls** **,** then creates a 100 Material Definitions (Mat001, Mat002,...Mat100), and finally adds all the material definitions to the **LargeMatCls** Material Class.

![](/resources/Storage/knowledge-base/creating-material-and-supplemental-equipment-through-scripting-3-0/image2022-12-27_15-33-3.png)

### Applies To and Version Info

This feature applies to the Track & Trace Module and is available in all versions.
 ## Scripting

The general syntax of the script function.

Generate a Large Number of Material Definitions

Code

```
matCls = system.mes.createMESObject('MaterialClass')
matCls.setPropertyValue('Name', 'LargeMatCls')
system.mes.saveMESObject(matCls)

matCls = system.mes.loadMESObject('LargeMatCls', 'MaterialClass')

numOfMatObjects = 100	#Create 100 material objects

for cnt in range(1, numOfMatObjects + 1):
	name = 'Mat%03d' % cnt
	mat = system.mes.createMESObject('MaterialDef')
	mat.setPropertyValue('Name', name)
	matCls.addChild(mat)
	system.mes.saveMESObject(mat)
	print 'Created %s' % name

system.mes.saveMESObject(matCls)
```


Output

Code

```
Jython 2.5.3 (v2.5.3:3d2dbae23c52+, Nov 17 2012, 11:51:23) 
[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.8.0_91

>>> 
True
True
Created Mat001
True
Created Mat002
True
Created Mat003
True
Created Mat004
True
Created Mat005
True
Created Mat006
True
Created Mat007
True
Created Mat008
True
Created Mat009
....
```

 For an "on the fly" example with supplemental equipment, consider a case where a parts manufacturing line has numbered bins for transporting parts. The facility adds bins with unique numbers regularly and needs a button to create a new bin that can only hold one lot. Furthermore, we want the bin to be a member of an Equipment Class in order to facilitate searches and quick selection using an MES Object Selector component. Therefore we must add the parent class to the new equipment.

On The Fly Supplemental Equipment Example

Code

```
##Get the new equipment name from the operator
val = '00001'
 
##Get the parent object for the new equipment object	
parent = system.mes.loadMESObject('Product Bins', 'EquipmentClass')

##Create new equipment object
obj = system.mes.createMESObject('Equipment')

##Set the name
obj.setPropertyValue('Name', val)

##Set the lot handling mode to "Single Lot"
prop = 'Single Lot'
obj.setPropertyValue('EquipmentLotHandlingMode', prop)

##Add the parent object to the new equipment object
obj.addParent(parent)

##Save the new object to manifest the changes.
system.mes.saveMESObject(obj)


```


## References

Material Class

Material Definition

Equipment Class

## Keywords

**Track & Trace, Scripting, Material Class, Material Definition, MES Object**