MES 3.0

For manufacturing tasks involving materials, the system represents material resources with material objects.  The material may be raw material that goes into finished goods, or it may be a consumable or by-product that is not directly related to the finished good. 

Material Examples:

  • raw material
  • consumable
  • by-product

There are two types of Material Objects: MaterialClass  and  MaterialDef. They inherit from the AbstractMESObject. Material Objects do not extend the AbstractMESObject.

On this page:





The MES 3.0 platform implements the ISA-95 Equipment Hierarchy model and object model.  The AbstractMESObject implements the objects defined by ISA as well as other useful MES objects. All objects that inherit from the AbstractMESObject share properties, functions and events.

AbstractMESObject:

Object Creation

system.mes.loadMESObject() inherits from the AbstractMESObject


Code Example
Code Snippet
#Get the MES object for a given name and MES object type
obj = system.mes.loadMESObject('Balsamic Vinegar', 'MaterialDef')
Code Snippet
#If an MES Object Link object was returned from a scripting or object function, then the following will return the full MES object instance
obj = objLink.getMESObject()



(click the diagram to zoom)

Versioning

Every time a MaterialDef or MaterialClass Object is modified, i.e. adding custom properties, changing a setting etc., the version number of that resource object is updated in the background. When an operation is scheduled, it checks for a corresponding responseMaterialClass or responseMaterialDef object version.

If one does not exist, it automatically create one. This versioning is not part of ISA-95, however, without it, analysis of historical data would lose the original configuration of equipment, personnel and materials.

Material Class 

This object is used to group material into a category. It can have MaterialDef or other MaterialClass objects as children. Defining production tasks for each specific material, is very tedious. A better method is to organize the material into categories (or classes using ISA-95 terms).

Consider receiving raw materials at a dock. Defining a task to receive each type of material would be painful and difficult to maintain. Instead all materials that maybe received can be added to a 'Raw Materials' class. Now when an operator receives material, the operation will prompt them for the specific material that must belong to the 'Raw Materials' class. Only one receive operation has to be defined which is much easi

getMESObject

To call MaterialClass and MaterialDef objects, use getMESObject.


The MaterialClass object inherits the AbstractMESObject properties and methods, but does not extend them.



Material Def

Material Definition objects are used to define materials that may be consumed or created throughout the manufacturing process. This can include raw materials, sub-assemblies, finished goods, scrap material and consumables.  The MaterialDef object inherits the AbstractMESObject properties and methods, but does not extend them.



Object Creation

Material Definition and Material Class objects are created using MES Object Editor component and OEE Material Manager - Vision component. See creating materials page for more details. 

ResponseMaterialDef and ResponseMaterialClass objects are automatically created by operations and are used for traceability analysis.

The following script function is used to create these objects.

Script Example
Code Snippet
# Create Material Class - Bulk Nuts
mat_class = system.mes.createMESObject('MaterialClass')
mat_class.setPropertyValue('Name','Bulk Nuts')
system.mes.saveMESObject(mat_class)
mat_class = system.mes.loadMESObject('Bulk Nuts','MaterialClass')

print "Created Material Class Name: %s" % mat_class.getName()

mat_list = ["Bulk Peanuts", "Bulk Walnuts", "Bulk Almonds"]

# Create Material Definitions under Material Class
# Bulk Nuts
# Bulk Almonds, Bulk Walnuts, Bulk Peanuts
for mat in mat_list:
	# Create Material Definition
	mat_def = system.mes.createMESObject('MaterialDef')
	mat_def.setPropertyValue('Name', mat)
	system.mes.saveMESObject(mat_def)
	mat_def = system.mes.loadMESObject(mat, 'MaterialDef')
	
	# Add Material Definition to Material Class
	mat_class.addChild(mat_def)
	
	print "Created Material Definition %s under %s" % (mat_def.getName(),mat_class.getName())

# Save off Material Class with it's new Material Definition Descendants
system.mes.saveMESObject(mat_class)

# New Material Class - Bulk Nuts 
# With children Material Definitons - Bulk Almonds, Bulk Peanuts, and Bulk Walnuts
mat_class = system.mes.loadMESObject('Bulk Nuts','MaterialClass')

Output
>>> 
True
Created Material Class Name: Bulk Nuts
True
Created Material Definition Bulk Peanuts under Bulk Nuts
True
Created Material Definition Bulk Walnuts under Bulk Nuts
True
Created Material Definition Bulk Almonds under Bulk Nuts
>>> 


Object Properties

This object inherits the AbstractMESObject properties...

The base AbstractMESObject object provides core properties that are common to all MES objects. The values of the core properties are accessed using the getPropertyValue() and setPropertyValue() functions of the AbstractMESObject object.




Core Properties

 Name
Type
Description
Nameread, write

This is the name of the MES object. This name is used when referencing the object. It must be a unique name meaning that no other MES object of its type can have the same name.

Naming Characters Allowed

Names must begin with a letter, digit or underscore. Subsequent characters may also include spaces and dashes. The following characters are not allowed:

ObjectCharacters not allowed
Production Equipment. ? ! # % ^ * ~ [ ] { } + = ` \, @ & ( ) < >
MES Person. ? ! # % ^ * ~ [ ] { } + = ` \/ " $ | < >
All other MES Objects. ? ! # % ^ * ~ [ ] { } + = ` \/ " $ | ,

UUIDread-onlyThis will contain the Universally Unique Identifier for each instance of a MES object.
Enabledread, writeThis property will be set to true when the MES object is active and usable. When MES objects are deleted they are still retained in the database and the Enabled setting is set to false. This is done to maintain past traceability information.
Descriptionread, writeAn optional setting to give more details for a MES object.


Code Examples
Read Object UUID Snippet
#Get MES object UUID example:
mesObject = system.mes.loadMESObject("Vinegar", "MaterialClass")
print mesObject.getPropertyValue('UUID')
Set Object Name Snippet
#Set MES object name example:
mesObject = system.mes.loadMESObject("Vinegar", "MaterialClass")
mesObject.setPropertyValue('Name', 'MyNewObjectName')



Object Functions

This object inherits the AbstractMESObject functions.

These functions can be used with all of the MES Objects.

Artifact Object Functions

Description

Create a new MES Artifact property named by artifactName on an existing MES Object, with a provided primitive, Pythonic or Java serializable object as the serializableValue (including strings, integer/real/float/double numbers and Boolean). The new MES Artifact is 'versioned' so each save creates a new version of the artifact (one additional row in the DB per version saved).

Files are also 'serializable' (Artifacts serialize the file as an array of bytes. Add "from java.io import File" to script and use File (fileName) where fileName contains the path to the file, with filename and extension. Refer to the Java Class File page).

Syntax

createArtifact(artifactName, serializableValue)


  • Parameters

String artifactName - the name of the 'versioned' MES Artifact to create. Name will be stored using lower-case letters.

Serializable serializableValue - Any primitive, Pythonic or Java serializable object (including strings, integer/real/float/double numbers and Boolean)Files are also 'serializable'.

  • Returns

MESArtifactProperty - A reference to the newly-created Artifact property.

  • Scope

All

Code Examples
Code Snippet
# Create a new 'versioned' MES Artifact object called 'my artifact' 
#    on the Material Definition 'Test Material' and set the value 
#    of the new Artifact to the string "Hello World".
obj = system.mes.loadMESObject('Test Material', 'MaterialDef')
obj.createArtifact('my artifact', 'Hello World')
system.mes.saveMESObject(obj)
Description

Create a new MES Artifact property named by artifactName on an existing MES Object, with a provided primitive, Pythonic or Java serializable object as the serializableValue (including strings, integer/real/float/double numbers and Boolean). 

Files are also 'serializable' (Artifacts serialize the file as an array of bytes. Add "from java.io import File" to script and use File (fileName) where fileName contains the path to the file, with filename and extension. Refer to the Java Class File page).

If versioned=FALSE, only one artifact with the version 0 is created and each save overwrites the previous value. If versioned=TRUE, then the artifact is saved with its timestamp, such that each save creates a new version of the artifact (one additional row in the DB per version saved).

Syntax

createArtifact(artifactName, serializableValue, versioned)


  • Parameters

String artifactName - the name of the Artifact to create. Name will be stored using lower-case letters.

Serializable serializableValue - Any primitive, Pythonic or Java serializable object (including strings, integer/real/float/double numbers and BooleanFiles are also 'serializable'.

Boolean versioned - FALSE means only one artifact is stored and is overwritten on each save. TRUE keeps a versioned copy with timestamp as an additional row in the database on each save.

  • Returns

MESArtifactProperty - A reference to the newly-created Artifact property.

  • Scope

All

Code Examples
Code Snippet
# Create a new 'unversioned' MES Artifact object called 'unversioned artifact' 
#    on the Material Definition 'Test Material' and set the value 
#    of the new Artifact to the string "Hello World".
obj = system.mes.loadMESObject('Test Material', 'MaterialDef')
obj.createArtifact('unversioned artifact', 'Hello World', False)
system.mes.saveMESObject(obj)
Description

Returns the number of artifacts that exist for this MES Object.

Syntax

getArtifactCount()


  • Parameters

None

  • Returns

Integer - The number of artifacts that exist for this MES Object.

  • Scope

All

Code Examples
Code Snippet
# Code example
Description

Returns a list with the Name property for all artifacts that exist for this MES Object, as well as for all parent objects.

Syntax

getAllArtifactNames()


  • Parameters

None

  • Returns

List - A Pythonic list with the Name property for all artifacts that exist for this MES Objectas well as for all parent objects. Names have all been previously created with lower-case letters.

  • Scope

All

Code Examples
Code Snippet
# Code example
Description

Returns a list with the Name property for all artifacts that exist for this MES Object.

Syntax

getArtifactNames()


  • Parameters

None

  • Returns

List - A Pythonic list with the Name property for all artifacts that exist for this MES ObjectNames have all been previously created with lower-case letters.

  • Scope

All

Code Examples
Code Snippet
# Code example
Description

Returns the MES Artifact Property of the specified Artifact on the MES Object.

Syntax

getArtifactProperty(artifactName)


  • Parameters

String artifactName - The Name of the Artifact on the MES ObjectNames have all been previously created with lower-case letters.

  • Returns

MESArtifactProperty - The MES Artifact Property of the specified Artifact on the MES Object.

  • Scope

All

Code Examples
Code Snippet
# Code example
Description

Returns all of the MES Artifact Properties of the specified Artifact on the MES Object.

Syntax

getArtifactProperties()


  • Parameters

None

  • Returns

MESPropertyCollection - All of the MES Artifact Properties of the specified Artifact on the MES Object.

  • Scope

All

Code Examples
Code Snippet
# Code example
Description

Returns the value of the Artifact on the MES Object specified by the Artifact's Name.

Syntax

getArtifactValueByName(artifactName)


  • Parameters

String artifactName - The Name of the Artifact on the MES ObjectNames have all been previously created with lower-case letters.

  • Returns

Serializable - The primitive, Pythonic or Java serializable object value stored for the Artifact on the MES ObjectFiles are also 'serializable', so file contents are returned as an array of bytes.

  • Scope

All

Code Examples
Code Snippet
obj = system.mes.loadMESObject('Widget A', 'MaterialDef')
ds = obj.getArtifactValueByName('test data')
print ds ##prints data set.
Description

Returns the value of the Artifact on the MES Object specified by the Artifact's UUID.

Syntax

getArtifactValueByUUID(artifactName)


  • Parameters

String artifactUUID - The UUID of the Artifact on the MES Object.

  • Returns

Serializable - The primitive, Pythonic or Java serializable object value stored for the Artifact on the MES ObjectFiles are also 'serializable', so file contents are returned as an array of bytes.

  • Scope

All

Code Examples
Code Snippet
# Code example
Description

Updates an existing MES Artifact property named by artifactName on an existing MES Object, with a provided primitive, Pythonic or Java serializable object as the serializableValue (including strings, integer/real/float/double numbers and Boolean). 

Files are also 'serializable' (Artifacts serialize the file as an array of bytes. Add "from java.io import File" to script and use File (fileName) where fileName contains the path to the file, with filename and extension. Refer to the Java Class File page).

Syntax

setArtifactValue(artifactName, serializableValue)


  • Parameters

String artifactName - the name of the Artifact to update. Names have all been previously created with lower-case letters.

Serializable serializableValue - Any primitive, Pythonic or Java serializable object (including strings, integer/real/float/double numbers and Boolean)Files are also 'serializable'.

  • Returns

Nothing

  • Scope

All

Code Examples
Code Snippet
# Code example

Object Functions

Description

Add a MES object as a child to another MES object. MES objects can have children and parents. Depending on the type of MES object determines the types of children or parents that can be added. For example, a material class (MESMaterialClass) object can have material definitions (MESMaterialDef) as children, but material definitions objects cannot have material class objects as children.

Note

When a child is added to an MES object, then a parent reference will be added to the child behind the scenes. Likewise, when a parent is added to a child, a child reference will be added to the parent behind the scenes. This insures if integrity of relationships are maintained.

Syntax

addChild(mesObject)


  • Parameters

AbstractMESObject mesObject - An instance to an MES object. An AbstractMESObject object is just the generic form of an MES object when the specific type is unknown.

  • Returns

Nothing

  • Scope

All

Code Examples
Code Snippet
#Get the Screws material class object
matCls = system.mes.loadMESObject('Screws', 'MaterialClass')
 
#Get the 10-32 NC Screw material definition object
matDef = system.mes.loadMESObject('10-32 NC Screw', 'MaterialDef')
 
#Add the 10-32 NC Screw material definition object as a child to the Screws material class object
matCls.addChild(matDef)
 
#Save the changes
system.mes.saveMESObject(matCls)
Description

Add a MES object link as a child to another MES object. MES objects can have children and parents. Depending on the type of MES object determines the types of children or parents that can be added. For example, a material class (MESMaterialClass) object can have material definitions (MESMaterialDef) as children, but material definitions objects cannot have material class objects as children.

Note

When a child is added to an MES object, then a parent reference will be added to the child behind the scenes. Likewise, when a parent is added to a child, a child reference will be added to the parent behind the scenes. This insures if integrity of relationships are maintained.

Syntax

addChild(mesObject)


  • Parameters

MES Object Link mesObjectLink - A link to an MES object. A MES Object Link holds identification information to a MES object. This is very efficient when displaying MES objects in a list and all the MES object details are not needed.

  • Returns

Nothing

  • Scope

All

Code Examples
Code Snippet
#Get the Storage Tanks equipment class object
eqCls = system.mes.loadMESObject('Storage Tanks', 'EquipmentClass')
 
#Get the Tank 1A equipment object from the equipment path
eq = system.mes.getMESObjectLinkByEquipmentPath('[global]\Dressings Inc\California\Raw Materials\Tank Farm\Tank 1A')
 
#Add the 10-32 NC Screw material definition object as a child to the Screws material class object
eqCls.addChild(eq)
 
#Save the changes
system.mes.saveMESObject(eqCls)
Description

Custom properties can be added to MES objects or even complex properties (such as a material, equipment or personnel reference) of an MES object. The AbstractMESObject Functions method can be used to add a custom property directly to a MES object by not specifying a path to the parent property. To add a custom property as a child of an existing custom property or to a complex property, the parent path is used to specify the parent.

Each level of the path is separated with a period. This allows for names to be duplicated provided the path is unique. For example, it is possible for a MES object to have custom properties "Dimension 1.Width" and "Dimension 2.Width"

Syntax

addCustomProperty(name, dataTypeName, description, units, productionVisible, required, value)


  • Parameters

String name - Name of the custom property to add.

String dataTypeName - Name of the Ignition data type to make the new custom property. Options: Int1, Int2, Int4, Int8, Float4, Float8, Boolean, String, DateTime, Text, Int1Array, Int2Array, Int4Array, Int8Array, Float4Array, Float8Array, BooleanArray, StringArray, DateTimeArray.

String description - The description of the custom property.

String units - The units of the new custom property. This is just for reference.

boolean productionVisible - The default is false. If True, show the custom property in various components. If False, it will be hidden and can be used to store values behind the scenes.

boolean required - If True, a value must be assigned to the custom property before and segment is ended.

String value - The value to assign to the custom property after it has been added. Note that this value is cast to a string, even if the custom property is not a string.

  • Returns

Nothing

  • Scope

All

Code Examples
Code Snippet
#Load a MES object
obj = system.mes.loadMESObject('Box', 'MaterialDef')
 
#Add Type custom property directly to the MES object
obj.addCustomProperty('Type', 'String')
 
#Add Dimension custom property directly to the MES object
obj.addCustomProperty('Dimension', 'String', 'Dimension of box', '', True, False)
 
#Add Width custom property to the previous Dimension custom property and assign a value
obj.addCustomProperty('Dimension', 'Width', 'Int4', 'Width of box', 'in', True, False, '24')
 
#Add Height custom property to the previous Dimension custom property and assign a value
obj.addCustomProperty('Dimension', 'Height', 'Int4', 'Height of box', 'in', True, False, '12')
 
#Type custom property was never assigned a value so None is returned
print obj.getPropertyValue('Type')
 
#Remember to save the MES object
system.mes.saveMESObject(obj)
 
#Width and Height custom properties were assigned values
print obj.getPropertyValue('Dimension.Width')
print obj.getPropertyValue('Dimension.Height')
Output
None
24
12
Description

Custom properties can be added to MES objects or even complex properties (such as a material, equipment or personnel reference) of an MES object. The AbstractMESObject Functions method can be used to add a custom property directly to a MES object by not specifying a path to the parent property. To add a custom property as a child of an existing custom property or to a complex property, the parent path is used to specify the parent.

Each level of the path is separated with a period. This allows for names to be duplicated provided the path is unique. For example, it is possible for a MES object to have custom properties "Dimension 1.Width" and "Dimension 2.Width"

Syntax

addCustomProperty(name, dataTypeName, description, units, productionVisible, required)


  • Parameters

String name - The name of the custom property to add.

String dataTypeName - Name of the Ignition data type to make the new custom property. Options: Int1, Int2, Int4, Int8, Float4, Float8, Boolean, String, DateTime, Text, Int1Array, Int2Array, Int4Array, Int8Array, Float4Array, Float8Array, BooleanArray, StringArray, DateTimeArray.

String description - The description of the custom property.

String units - The units of the new custom property. This is just for reference.

boolean productionVisible - The default is false. If True, show the custom property in various components. If False, it will be hidden and can be used to store values behind the scenes.

boolean required - If True, a value must be assigned to the custom property before and segment is ended.

  • Returns

Nothing

  • Scope

All

Code Examples
Code Snippet
#Load a MES object
obj = system.mes.loadMESObject('Box', 'MaterialDef')
 
#Add Type custom property directly to the MES object
obj.addCustomProperty('Type', 'String')
 
#Add Dimension custom property directly to the MES object
obj.addCustomProperty('Dimension', 'String', 'Dimension of box', '', True, False)
 
#Add Width custom property to the previous Dimension custom property and assign a value
obj.addCustomProperty('Dimension', 'Width', 'Int4', 'Width of box', 'in', True, False, '24')
 
#Add Height custom property to the previous Dimension custom property and assign a value
obj.addCustomProperty('Dimension', 'Height', 'Int4', 'Height of box', 'in', True, False, '12')
 
#Type custom property was never assigned a value so None is returned
print obj.getPropertyValue('Type')
 
#Remember to save the MES object
system.mes.saveMESObject(obj)
 
#Width and Height custom properties were assigned values
print obj.getPropertyValue('Dimension.Width')
print obj.getPropertyValue('Dimension.Height')
Output
None
24
12
Description

Custom properties can be added to MES objects or even complex properties (such as a material, equipment or personnel reference) of an MES object. The AbstractMESObject Functions method can be used to add a custom property directly to a MES object by not specifying a path to the parent property. To add a custom property as a child of an existing custom property or to a complex property, the parent path is used to specify the parent.

Each level of the path is separated with a period. This allows for names to be duplicated provided the path is unique. For example, it is possible for a MES object to have custom properties "Dimension 1.Width" and "Dimension 2.Width"

Syntax

addCustomProperty(name, dataTypeName)


  • Parameters

String name - The name of the custom property to add.

String dataTypeName - Name of the Ignition data type to make the new custom property. Options: Int1, Int2, Int4, Int8, Float4, Float8, Boolean, String, DateTime, Text, Int1Array, Int2Array, Int4Array, Int8Array, Float4Array, Float8Array, BooleanArray, StringArray, DateTimeArray.

  • Returns

Nothing

  • Scope

All

Code Examples
Code Snippet
#Load a MES object
obj = system.mes.loadMESObject('Box', 'MaterialDef')
 
#Add Type custom property directly to the MES object
obj.addCustomProperty('Type', 'String')
 
#Add Dimension custom property directly to the MES object
obj.addCustomProperty('Dimension', 'String', 'Dimension of box', '', True, False)
 
#Add Width custom property to the previous Dimension custom property and assign a value
obj.addCustomProperty('Dimension', 'Width', 'Int4', 'Width of box', 'in', True, False, '24')
 
#Add Height custom property to the previous Dimension custom property and assign a value
obj.addCustomProperty('Dimension', 'Height', 'Int4', 'Height of box', 'in', True, False, '12')
 
#Type custom property was never assigned a value so None is returned
print obj.getPropertyValue('Type')
 
#Remember to save the MES object
system.mes.saveMESObject(obj)
 
#Width and Height custom properties were assigned values
print obj.getPropertyValue('Dimension.Width')
print obj.getPropertyValue('Dimension.Height')
Output
None
24
12
Description

Custom properties can be added to MES objects or even complex properties (such as a material, equipment or personnel reference) of an MES object. The AbstractMESObject Functions method can be used to add a custom property directly to a MES object by not specifying a path to the parent property. To add a custom property as a child of an existing custom property or to a complex property, the parent path is used to specify the parent.

Each level of the path is separated with a period. This allows for names to be duplicated provided the path is unique. For example, it is possible for a MES object to have custom properties "Dimension 1.Width" and "Dimension 2.Width"

Syntax

addCustomProperty(parentPath, name, dataTypeName, description, units, productionVisible, required, value)


  • Parameters

String parentPath - The path of the parent to add the custom property to.

String name - The name of the custom property to add.

String dataTypeName - Name of the Ignition data type to make the new custom property. Options: Int1, Int2, Int4, Int8, Float4, Float8, Boolean, String, DateTime, Text, Int1Array, Int2Array, Int4Array, Int8Array, Float4Array, Float8Array, BooleanArray, StringArray, DateTimeArray.

String description - The description of the custom property.

String units - The units of the new custom property. This is just for reference.

boolean productionVisible - The default is false. If True, show the custom property in various components. If False, it will be hidden and can be used to store values behind the scenes.

boolean required - If True, a value must be assigned to the custom property before and segment is ended.

String value - The value to assign to the custom property after it has been added. Note that this value is cast to a string, even if the custom property is not a string.

  • Returns

Nothing

  • Scope

All

Code Examples
Code Snippet
#Load a MES object
obj = system.mes.loadMESObject('Box', 'MaterialDef')
 
#Add Type custom property directly to the MES object
obj.addCustomProperty('Type', 'String')
 
#Add Dimension custom property directly to the MES object
obj.addCustomProperty('Dimension', 'String', 'Dimension of box', '', True, False)
 
#Add Width custom property to the previous Dimension custom property and assign a value
obj.addCustomProperty('Dimension', 'Width', 'Int4', 'Width of box', 'in', True, False, '24')
 
#Add Height custom property to the previous Dimension custom property and assign a value
obj.addCustomProperty('Dimension', 'Height', 'Int4', 'Height of box', 'in', True, False, '12')
 
#Type custom property was never assigned a value so None is returned
print obj.getPropertyValue('Type')
 
#Remember to save the MES object
system.mes.saveMESObject(obj)
 
#Width and Height custom properties were assigned values
print obj.getPropertyValue('Dimension.Width')
print obj.getPropertyValue('Dimension.Height')
Output
None
24
12
Description

Custom properties can be added to MES objects or even complex properties (such as a material, equipment or personnel reference) of an MES object. The AbstractMESObject Functions method can be used to add a custom property directly to a MES object by not specifying a path to the parent property. To add a custom property as a child of an existing custom property or to a complex property, the parent path is used to specify the parent.

Each level of the path is separated with a period. This allows for names to be duplicated provided the path is unique. For example, it is possible for a MES object to have custom properties "Dimension 1.Width" and "Dimension 2.Width"

Syntax

addCustomProperty(parentPath, name, dataTypeName, description, units, productionVisible, required)


  • Parameters

String parentPath - The path of the parent to add the custom property to.

String name - The name of the custom property to add.

String dataTypeName - Name of the Ignition data type to make the new custom property. Options: Int1, Int2, Int4, Int8, Float4, Float8, Boolean, String, DateTime, Text, Int1Array, Int2Array, Int4Array, Int8Array, Float4Array, Float8Array, BooleanArray, StringArray, DateTimeArray.

String description - The description of the custom property.

String units - The units of the new custom property. This is just for reference.

boolean productionVisible - The default is false. If True, show the custom property in various components. If False, it will be hidden and can be used to store values behind the scenes.

boolean required - If True, a value must be assigned to the custom property before and segment is ended.

  • Returns

Nothing

  • Scope

All

Code Examples
Code Snippet
#Load a MES object
obj = system.mes.loadMESObject('Box', 'MaterialDef')
 
#Add Type custom property directly to the MES object
obj.addCustomProperty('Type', 'String')
 
#Add Dimension custom property directly to the MES object
obj.addCustomProperty('Dimension', 'String', 'Dimension of box', '', True, False)
 
#Add Width custom property to the previous Dimension custom property and assign a value
obj.addCustomProperty('Dimension', 'Width', 'Int4', 'Width of box', 'in', True, False, '24')
 
#Add Height custom property to the previous Dimension custom property and assign a value
obj.addCustomProperty('Dimension', 'Height', 'Int4', 'Height of box', 'in', True, False, '12')
 
#Type custom property was never assigned a value so None is returned
print obj.getPropertyValue('Type')
 
#Remember to save the MES object
system.mes.saveMESObject(obj)
 
#Width and Height custom properties were assigned values
print obj.getPropertyValue('Dimension.Width')
print obj.getPropertyValue('Dimension.Height')
Output
None
24
12
Description

Custom properties can be added to MES objects or even complex properties (such as a material, equipment or personnel reference) of an MES object. The AbstractMESObject Functions method can be used to add a custom property directly to a MES object by not specifying a path to the parent property. To add a custom property as a child of an existing custom property or to a complex property, the parent path is used to specify the parent.

Each level of the path is separated with a period. This allows for names to be duplicated provided the path is unique. For example, it is possible for a MES object to have custom properties "Dimension 1.Width" and "Dimension 2.Width"

Syntax

addCustomProperty(parentPath, name, dataTypeName)


  • Parameters

String parentPath - The path of the parent to add the custom property to.

String name - The name of the custom property to add.

String dataTypeName - Name of the Ignition data type to make the new custom property. Options: Int1, Int2, Int4, Int8, Float4, Float8, Boolean, String, DateTime, Text, Int1Array, Int2Array, Int4Array, Int8Array, Float4Array, Float8Array, BooleanArray, StringArray, DateTimeArray.

  • Returns

Nothing

  • Scope

All

Code Examples
Code Snippet
#Load a MES object
obj = system.mes.loadMESObject('Box', 'MaterialDef')
 
#Add Type custom property directly to the MES object
obj.addCustomProperty('Type', 'String')
 
#Add Dimension custom property directly to the MES object
obj.addCustomProperty('Dimension', 'String', 'Dimension of box', '', True, False)
 
#Add Width custom property to the previous Dimension custom property and assign a value
obj.addCustomProperty('Dimension', 'Width', 'Int4', 'Width of box', 'in', True, False, '24')
 
#Add Height custom property to the previous Dimension custom property and assign a value
obj.addCustomProperty('Dimension', 'Height', 'Int4', 'Height of box', 'in', True, False, '12')
 
#Type custom property was never assigned a value so None is returned
print obj.getPropertyValue('Type')
 
#Remember to save the MES object
system.mes.saveMESObject(obj)
 
#Width and Height custom properties were assigned values
print obj.getPropertyValue('Dimension.Width')
print obj.getPropertyValue('Dimension.Height')
Output
None
24
12
Description

Add a MES object as a parent to another MES object. MES objects can have children and parents. Depending on the type of MES object determines the types of children or parents that can be added. For example, a material class (MESMaterialClass) object can have material definitions (MESMaterialDef) as children, but material definitions objects cannot have material class objects as children.

Note

When a child is added to an MES object, then a parent reference will be added to the child behind the scenes. Likewise, when a parent is added to a child, a child reference will be added to the parent behind the scenes. This insures if integrity of relationships are maintained.

Add Parent before Naming for Non-Unique Names

Some MES Objects can have duplicate names, such as lines in different areas.  However, lines in the same area must have unique names.  Ensure that object.addParent() is called before obj.setPropertyValue('Name', 'Non-Unique Name') in any script creating such non-uniquely named equipment that requires distinct parents or paths.

Syntax

addParent(mesObject)


  • Parameters

AbstractMESObject mesObject - An instance to an MES object. An AbstractMESObject object is just the generic form of an MES object when the specific type is unknown.

  • Returns

Nothing

  • Scope

All

Code Examples
Code Snippet
#Get the 10-32 NC Screw material definition object
matDef = system.mes.loadMESObject('10-32 NC Screw', 'MaterialDef')

#Get the Screws material class object
matCls = system.mes.loadMESObject('Screws', 'MaterialClass')
 
#Add the Screws material class object as a parent to the 10-32 NC Screw material definition object
matDef.addParent(matCls)
 
#Save the changes
system.mes.saveMESObject(matDef)
Description

Add a MES object link as a parent to another MES object. MES objects can have children and parents. Depending on the type of MES object determines the types of children or parents that can be added. For example, a material class (MESMaterialClass) object can have material definitions (MESMaterialDef) as children, but material definitions objects cannot have material class objects as children.

Note

When a child is added to an MES object, then a parent reference will be added to the child behind the scenes. Likewise, when a parent is added to a child, a child reference will be added to the parent behind the scenes. This insures if integrity of relationships are maintained.

Syntax

addParent(mesObject)


  • Parameters

MES Object Link mesObjectLink - A link to an MES object. A MES Object Link holds identification information to a MES object. This is very efficient when displaying MES objects in a list and all the MES object details are not needed.

  • Returns

Nothing

  • Scope

All

Code Examples
Code Snippet
#Get the Tank 1A equipment object from the equipment path
eq = system.mes.getMESObjectLinkByEquipmentPath('[global]\Dressings Inc\California\Raw Materials\Tank Farm\Tank 1A')

#Get the Storage Tanks equipment class object
eqCls = system.mes.loadMESObject('Storage Tanks', 'EquipmentClass')
  
#Add the Screws material class object to the 10-32 NC Screw material definition object
eq.addChild(eqCls)
 
#Save the changes
system.mes.saveMESObject(eq)

Description

Create a complex property directly to an MES object by not specifying a path to the parent property.

Syntax

createComplexProperty(complexPropertyType, name)


  • Parameters

String complexPropertyType - The type of complex property.

String name - The name of complex property.

  • Returns

The complex property for the specified type (Material Resource Property, Equipment Resource Property, Personnel Resource Property, etc.)

  • Scope

All

Code Examples
Code Snippet
od = system.mes.createMESObject('OperationsDefinition')
 
#Load the process segment to base the operations segments on
ps = system.mes.loadMESObject('Receive Material', 'ProcessSegment')
depProp = od.createComplexProperty('SegmentDependency', ps.getName())
 
#Derive a new operation segment from the process segment
os = system.mes.deriveMESObject(ps, 'OperationsSegment', True)
depProp.setSegmentRefType('OperationsSegment')
depProp.setSegmentRefUUID(os.getUUID())
print depProp
Output
{SegmentRef=Operations Segment, , SegmentRefUUID=cfabeb4a-0b2d-4e43-91a8-1258d8b41e32, SegmentRefType=OperationsSegment, SegmentDependencyType=null, SegmentDependencyFactor=null, SegmentDependencyFactorUnits=null}
Description

Returns all the custom properties for the definition and any class object that the definition is a member of plus the inherited custom properties as a list of MESCustomProperty objects.

Syntax

getAllCustomProperties()


  • Parameters

None

  • Returns

List<MESCustomProperty> - The list of custom properties.

  • Scope

All

Code Examples
Code Snippet
matDef = system.mes.loadMESObject('Cane Sugar', 'MaterialDef')
matDef.getAllCustomProperties()

Description

Get the collection of children for an MES object.

Syntax

getChildCollection()


  • Parameters

None

  • Returns

MESObjectCollection - Returns a collection object containing references to all children of the MES object.

  • Scope

All

Code Examples
Code Snippet
#This example reads and prints the name of all child MES objects that belong to the Vinegar Material Class.
mesObject = system.mes.loadMESObject('Vinegar', 'MaterialClass')
 
if mesObject != None:
    childList = mesObject.getChildCollection().getList()
    for child in childList:
		
		#The child variable is of the MESObjectLink type
        print child.getName()
Output
Balsamic Vinegar
Red Wine Vinegar
White Vinegar

Description

Get the collection of complex properties.

Syntax

getComplexProperty(complexPropertyName, entryName)


  • Parameters

String complexPropertyName - The name for the type of complex property.

String entryName - The name of the complex property entry.

  • Returns

The complex property collection.

  • Scope

All

Code Examples
Code Snippet
seg = system.mes.createMESObject('ProcessSegment')
 
#Create a new material reference complex property
materialProp = seg.createComplexProperty('Material', 'Vinegar')
print seg.getComplexProperty('Material','Vinegar')
Output
{MaterialOptional=false, MaterialProductionSelectable=true, MaterialUse=null, MaterialAutoGenerateLot=false, MaterialRef=, MaterialRefUUID=null, MaterialRefType=null, MaterialEquipmentRef=, MaterialEquipmentRefType=null, MaterialEquipmentRefUUID=null, MaterialEnableSublots=false, MaterialLotNoSource=null, MaterialLotNoSourceLink=null, MaterialQuantitySource=null, MaterialQuantitySourceLink=null, MaterialQuantity=null, MaterialUnits=null, MaterialRatePeriod=null, MaterialRate=null, MaterialCycleTime=0, MaterialFinalLotStatus=null, MaterialAutoLotCompletion=Disabled, MaterialLotDepletionWarning=0, MaterialLotStatusFilter=null}
Description

Get the collection of complex properties.

Syntax

getComplexProperty(complexPropertyName, index)


  • Parameters

String complexPropertyName - The name for the type of complex property.

Integer index - The specified position in this list.

  • Returns

The complex property collection.

  • Scope

All

Code Examples
Code Snippet
seg = system.mes.createMESObject('ProcessSegment')
 
#Create a new material reference complex property
materialProp = seg.createComplexProperty('Material', 'Vinegar')
print seg.getComplexProperty('Material', 0)
Output
{MaterialOptional=false, MaterialProductionSelectable=true, MaterialUse=null, MaterialAutoGenerateLot=false, MaterialRef=, MaterialRefUUID=null, MaterialRefType=null, MaterialEquipmentRef=, MaterialEquipmentRefType=null, MaterialEquipmentRefUUID=null, MaterialEnableSublots=false, MaterialLotNoSource=null, MaterialLotNoSourceLink=null, MaterialQuantitySource=null, MaterialQuantitySourceLink=null, MaterialQuantity=null, MaterialUnits=null, MaterialRatePeriod=null, MaterialRate=null, MaterialCycleTime=0, MaterialFinalLotStatus=null, MaterialAutoLotCompletion=Disabled, MaterialLotDepletionWarning=0, MaterialLotStatusFilter=null}
Description

Get the collection of complex properties.

Syntax

getComplexProperty(path)


  • Parameters

String The path to the MES property to get.

  • Returns

The complex property for the specified path.

  • Scope

All

Code Examples
Code Snippet
seg = system.mes.createMESObject('ProcessSegment')
 
#Create a new material reference complex property
materialProp = seg.createComplexProperty('Material', 'Vinegar')
print seg.getComplexProperty('Material.Vinegar')
Output
{MaterialOptional=false, MaterialProductionSelectable=true, MaterialUse=null, MaterialAutoGenerateLot=false, MaterialRef=, MaterialRefUUID=null, MaterialRefType=null, MaterialEquipmentRef=, MaterialEquipmentRefType=null, MaterialEquipmentRefUUID=null, MaterialEnableSublots=false, MaterialLotNoSource=null, MaterialLotNoSourceLink=null, MaterialQuantitySource=null, MaterialQuantitySourceLink=null, MaterialQuantity=null, MaterialUnits=null, MaterialRatePeriod=null, MaterialRate=null, MaterialCycleTime=0, MaterialFinalLotStatus=null, MaterialAutoLotCompletion=Disabled, MaterialLotDepletionWarning=0, MaterialLotStatusFilter=null}
Description

This method is used to reference properties with various MES object types that have the same property kind and base names.

Options for Kind

  • Material
  • Equipment
  • SupplEquip
  • Personnel

Sample MES property paths:

  • Material.Vinegar.LotNo - where Material is the kind, Vinegar is the base name and LotNo is the property name.
  • Response Material.Vinegar-1.LotNo - where Response Material is the name of the complex property type, Vinegar-1 is the entry name and LotNo is the property name.
Syntax

getComplexPropertyByKind(path)


  • Parameters

String path - The path to the MES property to get. Options for Kind are Material, Equipment, SupplEquip, and Personnel.

  • Returns

AbstractMESProperty - An AbstractMESProperty for the specified path.

  • Scope

All

Description

Get the number of complex properties.

Syntax

getComplexPropertyCount(complexPropertyName)


  • Parameters

String complexPropertyName - The name for the complex property.

  • Returns

Integer count - The size of the complex property collection.

  • Scope

All

Code Examples
Code Snippet
#This code snippet will print the size of complex property with name 'Material'
seg = system.mes.createMESObject('ProcessSegment')
 
#Create a new material reference complex property
materialProp = seg.createComplexProperty('Material', 'White Vinegar')
materialProp = seg.createComplexProperty('Material', 'Balsamic Vinegar')
materialProp = seg.createComplexProperty('Material', 'Red Wine Vinegar')
print seg.getComplexPropertyCount('Material')
Output
3
Description

Gets the list of production item with the specified complex property.

Syntax

getComplexPropertyItemNames(complexPropertyName)


  • Parameters

String complexPropertyName - The name of the complex property.

  • Returns

List<String> itemNameList - The list of production item names with the specified complex property.

  • Scope

All

Code Examples
Code Snippet
segName = 'Mixed Nuts 8oz-Nuts Unlimited:Folsom:Packaging:Packaging Line 1'
mesObject = system.mes.loadMESObject(segName, "OperationsSegment")
prodList = mesObject.getComplexPropertyItemNames('ProductionSettings')
for item in prodList:
    print item, " - ", mesObject.getComplexProperty('ProductionSettings',item).getModeRefProperty().getValue()
Output
Packaging Line 1 - Equipment Mode, Production
Packaging Line 1:Casepacker - Equipment Mode, Production
Packaging Line 1:Checkweigher - Equipment Mode, Production
Packaging Line 1:Filler - Equipment Mode, Production
Packaging Line 1:Palletizer - Equipment Mode, Production
Packaging Line 1:Labeler - Equipment Mode, Disabled
Description

Get the complex properties of a specific type.

Syntax

getComplexPropertyTypeNames()


  • Parameters

None

  • Returns

A list of complex properties that matches the given type.

  • Scope

All

Code Examples
Code Snippet
#This example prints the list of complex properties that matches the type 'Process Segment'.
seg = system.mes.loadMESObject('e9acd913-0ac2-497a-8c41-efa9285bd3ed')
 
#Create a new material reference complex property
materialProp = seg.createComplexProperty('Material', 'Vinegar')
print seg.getComplexPropertyTypeNames()
Output
[Material, Equipment, SupplEquip, Personnel]
Description

Get the collection of core properties.

Syntax

getCoreProperties()


  • Parameters

None

  • Returns

MESPropertyCollection coreProperties - The collection of core properties.

  • Scope

All

Description

Returns all of the custom properties of the definition object as an MESPropertyCollection.

Syntax

getCustomProperties()


  • Parameters

None

  • Returns

MESPropertyCollection - A collection of the names of custom properties as strings.

  • Scope

All

Code Examples
Code Snippet
matDef = system.mes.loadMESObject('Cane Sugar', 'MaterialDef')
print matDef.getCustomProperties()
Description

Return the custom properties for the MES object as a Python dictionary. The Python dictionary will contain custom property path, definition pairs. The definition is a Python list containing the data type, value, description, units, production visible and required settings of the custom property.

Because custom properties can be nested, the path of the custom property is used. Each level of the path is separated with a period. This allows for names to be duplicated provided the path is unique. For example, it is possible for a MES object to have custom properties "Dimension 1.Width" and "Dimension 2.Width"

Syntax

getCustomPropertiesFull()

  • Parameters

Nothing

  • Returns

PyDictionary - A Python dictionary containing custom property path (name) definition pairs.

  • Scope

All

Code Examples
Code Snippet
#Get the full custom property definitions for a MES object
cp = obj.getCustomPropertiesFull()
 
#Print the Python dictionary of all custom properties
print cp

#Get the definition for just the Width custom property
widthDef = cp['Dimension.Width']
 
#Print the Python list for the Width custom property definition
print widthDef
 
#Print setting individually for the Width custom property
print widthDef[0]	#Data type
print widthDef[1]	#Value
print widthDef[2]	#Description
print widthDef[3]	#Units
print widthDef[4]	#Production Visible
print widthDef[5]	#Required
Output
{u'Dimension.Width': [u'Int8', u'10', u'Box width', u'in', True, False], u'Dimension': [u'String', u'', u'', u'', True, False], u'Dimension.Height': [u'Int8', u'12', u'Box height', u'in', True, False]}
[u'Int8', u'10', u'Box width', u'in', True, False]
Int8
10
Box width
in
True
False
Description

Return the custom properties for a complex property of a MES object as a Python dictionary. When the complex properties on a MES object (for example, a material reference) have custom properties, this method is used to get them by type and name. The Python dictionary will contain custom property path, definition pairs. The definition is a Python list containing the data type, value, description, units, production visible and required settings of the custom property.

Because custom properties can be nested, the path of the custom property is used. Each level of the path is separated with a period. This allows for names to be duplicated provided the path is unique. For example, it is possible for a MES object to have custom properties "Dimension 1.Width" and "Dimension 2.Width"

Syntax

getCustomPropertiesFull(complexPropertyName, entryName)


  • Parameters

String complexPropertyType - The name for the type of complex property.

String name - The name of the complex property entry.

  • Returns

PyDictionary - A Python dictionary containing custom property path (name) definition pairs.

  • Scope

All

Code Examples
Code Snippet
#Load a segment MES object
proSeg = system.mes.loadMESObject('Receive Steel', 'ProcessSegment')
 
#Get the custom property values for the Steel In material reference
cp = proSeg.getCustomPropertiesFull('Material', 'Steel In')
 
#Get the definition for just the Thickness custom property
cpDef = cp['Dimension.Thickness']
 
#Print the Python list for the Thickness custom property definition
print cpDef 
 
#Print setting individually for the Thickness custom property
print cpDef [0]	#Data type
print cpDef [1]	#Value
print cpDef [2]	#Description
print cpDef [3]	#Units
print cpDef [4]	#Production Visible
print cpDef [5]	#Required

Output
[u'Float8', u'100', u'Thickness of steel', u'1/1000th', True, True]
Float8
100
Thickness of steel
1/1000th
True
True
Description

Get the description of the custom property by name or property path.

Syntax

getCustomPropertyDescription(propertyPath)


  • Parameters

String propertyPath - The name or property path of the custom property to get the description for.

  • Returns

String description - The custom property description.

  • Scope

All

Code Examples
Code Snippet
#Load an MES object
obj = system.mes.loadMESObject('Box', 'MaterialDef')
 
#Add a custom property
obj.addCustomProperty('Kind', 'String', 'Kind of box', '', True, True)
 
#Print the current enabled state
print obj.getCustomPropertyDescription('Kind')
Output
Kind of box
Description

Get the enabled state of a custom property. If the enabled state is True then custom property is available. If False, the custom property will not appear in component, be used during production or is not accessible in script.

Syntax

getCustomPropertyEnabled(propertyPath)


  • Parameters

String propertyPath - The name or property path of the custom property to get the enabled state.

  • Returns

boolean The enabled state of the custom property.

  • Scope

All

Code Examples
Code Snippet
#Load an MES object
obj = system.mes.loadMESObject('Box', 'MaterialDef')
 
#Add a custom property
obj.addCustomProperty('Kind', 'String')
 
#Print the current enabled state
print obj.getCustomPropertyEnabled('Kind')

#Disable the custom property named Kind
obj.setCustomPropertyEnabled('Kind', False)

#Print the current enabled state
print obj.getCustomPropertyEnabled('Kind')
Output
True
False
Description

Get the units of the custom property.

Syntax

getCustomPropertyUnits(propertyPath)


  • Parameters

String propertyPath - The name or property path of the custom property to get the description for.

  • Returns

String units - The units of the new custom property.

  • Scope

All

Code Examples
Code Snippet
#Load MES object
obj = system.mes.loadMESObject('Box', 'MaterialDef')
print obj.getCustomPropertyUnits('Kind.Class of Box')
Output
lbs
Description

Return the custom properties for the complex property (resource reference) as a Python dictionary. The Python dictionary will contain custom property path, value pairs. Because custom properties can be nested, the path of the custom property is used. Each level of the path is separated with a period. This allows for names to be duplicated provided the path is unique. For example, it is possible for a MES object to have custom properties "Dimension 1.Widith" and "Dimension 2.Width".

For response segments, references to resources are created for each lot, person or supplemental equipment. For example, if a segment is started filling tank 1 and then switches to tank 2, then there will be two complex properties. One that has all the information while tank 1 was selected and a second that has all the information while tank 2 was selected. Custom properties can be added to the complex properties that will be unique for the time each tank was selected. If a pH reading is collected for each tank, then the separate readings can be saved in the appropriate complex property. To specify which complex property to access, extended naming is used. Referring to our sample, if we named the material complex property "Liquid", then the extend name for the first entry is "Liquid-1" and the second entry is "Liquid-2".

Syntax

getCustomPropertyValues(complexPropertyType, name)

  • Parameters

String complexPropertyType - The name for the type of complex property.

String name - The name of the complex property entry.

  • Returns

PyDictionary - A Python dictionary containing custom property path (name) value pairs.

  • Scope

All

Code Examples
Code Snippet
#Get the Storage Tanks equipment class object
proSeg = system.mes.loadMESObject('Receive Steel', 'ProcessSegment')
 
#Get the custom property values for the Steel In material reference
cp = proSeg.getCustomPropertyValues('Material', 'Steel In')
 
#Cycle through and print the custom property values
for path in cp.keys():
	print 'Path: %s = %s' % (path, cp[path])
print
 
#Just access a specific custom property by known path
print 'Dimension 1.Width = %s' % cp['Dimension 1.Width']
Description

Get properties inherited by the MES object. These inherited properties are custom properties on the parent(s) of the object.

Syntax

getInheritedProperties()


  • Parameters

None

  • Returns

MESPropertyCollection - The list of inherited properties.

  • Scope

All

Code Examples
Code Snippet
obj = system.mes.loadMESObject('Cashew Nuts', 'MaterialDef')
print obj.getInheritedProperties()
Description

Get the type of the MES object. This returns an object that represents the MES object type. This object contains other information associated with the type. In most cases only the name of the MES object type is needed and using the getMESObjectTypeName script function is recommended instead.

Syntax

getMESObjectType()


  • Parameters

None

  • Returns

MESObjectType - The type of MES object.

  • Scope

All

Code Examples
Code Snippet
#This example will print the type of MES object.
seg = system.mes.loadMESObject('e9acd913-0ac2-497a-8c41-efa9285bd3ed')
 
#Create a new material reference complex property
materialProp = seg.createComplexProperty('Material', 'Vinegar')
print seg.getMESObjectType()
Output
 Process Segment
Description

Get the name of the MES object type.

Syntax

getMESObjectTypeName()


  • Parameters

None

  • Returns

String - The MES object type name of the MES object. Refer to: MES Object Type Name.

  • Scope

All

Code Examples
Code Snippet
obj = system.mes.loadMESObject('Box', 'MaterialDef')
print obj.getMESObjectTypeName()
Output
Material Definition

Description

Get the name of the MES object. For each type of MES object, the name must be unique. For example, the name of each material definition is unique. In addition, the MES object name must also be unique for various categories of MES object types.

Syntax

getName()


  • Parameters

None

  • Returns

String - MES object name.

  • Scope

All

Info

Below are the categories of MES object types that the names will be unique:

CategoryMES Object Types
EquipmentEquipment, EquipmentClass
Material, PersonnelMaterialDef, MaterialClass, Person, Personnel Class
OperationOperations Definition, OperationSegment
Code Examples
Code Snippet
obj = system.mes.loadMESObject('Box', 'MaterialDef')
print obj.getName()
Output
Box
Code Examples
Code Snippet
#Example
obj = system.mes.loadMESObject('8da06ff8-2922-4e0c-a01a-e7cda6899a0e')
objLink = system.mes.object.link.create(obj)
print objLink.getName()
Output
Vinegar Tank 1

Description

Get the collection of parents for an MES object.

Syntax

getParentCollection()


  • Parameters

None

  • Returns

MESObjectCollection - Returns a collection object containing references to all parents of the MES object.

  • Scope

All

Code Examples
Code Snippet
#This example reads and prints the name of all parent MES objects that belong to Balsamic Vinegar.
mesObject = system.mes.loadMESObject('Balsamic Vinegar', 'MaterialDef')
 
if mesObject != None:
    parentList = mesObject.getParentCollection().getList()
    for parent in parentList:
		
		#The parent variable is of the MESObjectLink type
        print parent.getName()
Output
Vinegar
Description

Get a property value of an MES object by name or path. The property can be a core property, custom property or complex property of the MES object. In the case where custom properties are nested, a path is required to return the correct value.

The type of the value depends on the property being read. If no value is currently assigned to the property, None will be returned.

Syntax

getPropertyValue(propertyPath)


  • Parameters

String propertyPath - The name or path of the property being read.

  • Returns

The value of the property. The type depends on the property being read.

  • Scope

All

Code Examples
Code Snippet
#Load a MES object
obj = system.mes.loadMESObject('Box', 'MaterialDef')
 
#Read and print the Width and Height custom properties that are children of the Dimension custom property.
width = obj.getPropertyValue('Dimension.Width')
height = obj.getPropertyValue('Dimension.Height')
print "Width = %d, Height = %d" % (width, height)
Output
Width = 10, Height = 12
Description

Return the UUID value from the UUID property of the MES object. UUID stands for Universally Unique Identifier and each MES object will have a UUID assigned.

Syntax

getUUID()


  • Parameters

None

  • Returns

String - UUID of the MES object

  • Scope

All

Code Examples
Code Snippet
obj = system.mes.loadMESObject('Box', 'MaterialDef')
print obj.getUUID()
Output
b17159b6-81ce-4057-a5b3-626126079320
Description

Return the version number of the MES object. Not all MES objects have version number. Every time a definition type of MES object is modified, the version number is increased. When new schedules or production is run based on the definition MES object, it is tied the latest version of the definition MES objects.

Syntax

getVersion()


  • Parameters

None

  • Returns

Integer - The version number of this MES object.

  • Scope

All

Code Examples
Code Snippet
obj = system.mes.loadMESObject('Box', 'MaterialDef')
print obj.getVersion()
Output
3
Description

Get the enabled state of the MES object. If an MES object is not enabled, it will not show in any selection list or able to be selected within script. Essentially, the enabled state will change to false when the MES object is deleted. Deleted MES object still reside in the system for history of past production.

Syntax

isEnabled()


  • Parameters

None

  • Returns

boolean - The enabled state of the MES object.

  • Scope

All

Code Examples
Code Snippet
obj = system.mes.loadMESObject('Box', 'MaterialDef')
print obj.isEnabled()
Output
True
Description

If one or more properties of an MES object are changed, then True will be returned.

Syntax

isModified()


  • Parameters

None

  • Returns

boolean - The MES object modified state.

  • Scope

All

Code Examples
Code Snippet
#Load a MES object
obj = system.mes.loadMESObject('Box', 'MaterialDef')
print obj.isModified()
 
#Change a property of it
obj.setPropertyValue('Name', 'Empty Box')
print obj.isModified()
Output
False
True
Description

Remove another MES child object for an MES object.

MES objects can have children and parents. Depending on the type of MES object determines the types of children or parents that can be added. For example, a material class (MESMaterialClass) object can have material definitions (MESMaterialDef) as children, but material definitions objects cannot have material class objects as children.

Note

When a child is removed from an MES object, then the parent reference will be removed from the child behind the scenes. Likewise, when a parent is removed from a child, the child reference will be removed from the parent behind the scenes. This insures if integrity of relationships are maintained.

Syntax

removeChild(mesObject)


  • Parameters

AbstractMESObject mesObject - An instance to an MES object. An AbstractMESObject object is just the generic form of an MES object when the specific type is unknown.

  • Returns

Nothing

  • Scope

All

Code Examples
Code Snippet
#Get the Screws material class object
matCls = system.mes.loadMESObject('Screws', 'MaterialClass')
 
#Get the 10-32 NC Screw material definition object
matDef = system.mes.loadMESObject('10-32 NC Screw', 'MaterialDef')
 
#Remove the 10-32 NC Screw material definition object from the Screws material class object
matCls.removeChild(matDef)
 
#Save the changes
system.mes.saveMESObject(matCls)
Description

Removes an existing complex property.

Syntax

removeComplexProperty(complexPropertyName, entryName)


  • Parameters

String complexPropertyName - The name for the type of complex property.

String entryName - The name of the complex property entry.

  • Returns

Nothing

  • Scope

All

Code Examples
Code Snippet
seg = system.mes.createMESObject('ProcessSegment')
 
#In order to make it more clear, Let us create a complex property named Equipment. 
materialProp = seg.createComplexProperty('Equipment', 'Vinegar Tank1')
 
#This code snippet removed the complex property named 'Equipment'. So that when script function getComplexProperty() is executed it prints None.
removeProp = seg.removeComplexProperty('Equipment', 'Vinegar Tank1')
print seg.getComplexProperty('Equipment', 'Vinegar Tank1')
Output
None
Description

Removes an existing custom property.

Syntax

removeCustomProperty(propertyPath)


  • Parameters

String propertyPath - The path of property to remove.

  • Returns

Nothing

  • Scope

All

Code Examples
Code Snippet
#Load MES object
obj = system.mes.loadMESObject('Box', 'MaterialDef')
obj.removeCustomProperty('Kind.Class of Box') 
Description

Remove another MES parent object for an MES object.

MES objects can have children and parents. Depending on the type of MES object determines the types of children or parents that can be added. For example, a material class (MESMaterialClass) object can have material definitions (MESMaterialDef) as children, but material definitions objects cannot have material class objects as children.

Note

When a child is removed from an MES object, then the parent reference will be removed from the child behind the scenes. Likewise, when a parent is removed from a child, the child reference will be removed from the parent behind the scenes. This insures the integrity of relationships are maintained.

Syntax

removeParent(mesObject)


  • Parameters

AbstractMESObject mesObject - An instance to an MES object. An AbstractMESObject object is just the generic form of an MES object when the specific type is unknown.

  • Returns

Nothing

  • Scope

All

Code Examples
Code Snippet
#Get the 10-32 NC Screw material definition object
matDef = system.mes.loadMESObject('10-32 NC Screw', 'MaterialDef')

#Get the Screws material class object
matCls = system.mes.loadMESObject('Screws', 'MaterialClass')
 
#Remove the Screws material class object from the 10-32 NC Screw material definition object
matDef.removeParent(matCls)
 
#Save the changes
system.mes.saveMESObject(matDef)
Description

Renaming an existing complex property.

Syntax

renameComplexProperty(complexPropertyName, entryName, newEntryName)


  • Parameters

String complexPropertyName - The name for the type of complex property.

String entryName - The name of the complex property entry.

String newEntryName - The new complex property name.

  • Returns

Nothing

  • Scope

All

Code Examples
Code Snippet
seg = system.mes.createMESObject('ProcessSegment')
 
#Creates a complex property with name 'Equipment'
proSeg = seg.createComplexProperty('Equipment', 'Vinegar Tank1')
 
#Changes the name 'Vinegar Tank1' into 'Vinegar Tank2'
renameProp = seg.renameComplexProperty('Equipment', 'Vinegar Tank1', 'Vinegar Tank2')
Description

Rename an existing custom property.

Syntax

renameCustomProperty(propertyPath, newName)


  • Parameters

String propertyPath - The name or property path of the existing custom property to rename.

String newName - New custom property name.

  • Returns

Nothing

  • Scope

All

Code Examples
Code Snippet
#Load an MES object
obj = system.mes.loadMESObject('Box', 'MaterialDef')
 
#Add a custom property named Type
obj.addCustomProperty('Type', 'String')
 
#Remember to save the MES object
#system.mes.saveMESObject(obj)
 
#Print it to see the name of the new custom property
print obj.getCustomPropertiesFull()
 
#Rename the custom property from Type to Kind
obj.renameCustomProperty('Type', 'Kind')
 
#Print it to see the new custom property name
print obj.getCustomPropertiesFull()

#Remember to save the MES object
system.mes.saveMESObject(obj)

Output
{u'Type': [u'String', u'', u'', u'', False, False]}
{u'Kind': [u'String', u'', u'', u'', False, False]}
Description

Set the description of the custom property by name or property path.

Syntax

setCustomPropertyDescription(propertyPath, description)


  • Parameters

String propertyPath - The name or property path of the custom property to get the description for.

String description - The custom property description.

  • Returns

Nothing

  • Scope

All

Code Examples
Code Snippet
#Load an MES object
obj = system.mes.loadMESObject('Box', 'MaterialDef')
 
#Set a new description for Kind
obj.setCustomPropertyDescription('Kind', 'Class of Box')
 
#Prints the current description of the custom property.
print obj.getCustomPropertyDescription('Kind')
Output
Class of Box
Description

Set the enabled state of a custom property. If set to True then custom property is available. If False, the custom property will not appear in component, be used during production or is not accessible in script.

Syntax

setCustomPropertyEnabled(propertyPath, enable)


  • Parameters

String propertyPath - The name or property path of the custom property to set the enabled state.

boolean enable - The enabled state to set the custom property to.

  • Returns

Nothing

  • Scope

All

Code Examples
Code Snippet
#Load an MES object
obj = system.mes.loadMESObject('Box', 'MaterialDef')
 
#Add a custom property
obj.addCustomProperty('Kind', 'String')
 
#Print the current enabled state
print obj.getCustomPropertyEnabled('Kind')

#Disable the custom property named Kind
obj.setCustomPropertyEnabled('Kind', False)

#Print the current enabled state
print obj.getCustomPropertyEnabled('Kind')
Output
True
False
Description

Set the units of the custom property.

Syntax

setCustomPropertyUnits(propertyPath, units)


  • Parameters

String propertyPath - The name or property path of the custom property to get the description for.

String units - The units of the new custom property.

  • Returns

Nothing

  • Scope

All

Code Examples
Code Snippet
#Load MES object
obj = system.mes.loadMESObject('Box', 'MaterialDef')
obj.setCustomPropertyUnits('Kind.Class of Box','lbs')
print obj.getCustomPropertyUnits('Kind.Class of Box')
Output
lbs
Description

This method can be used to set custom properties values or create custom properties of an MES object. The format of the customProperties parameter determines if just custom property values will be assigned or custom properties will be created and values assigned.

Because custom properties can be nested, the path of the custom property is used. Each level of the path is separated with a period. This allows for names to be duplicated provided the path is unique. For example, it is possible for a MES object to have custom properties "Dimension 1.Width" and "Dimension 2.Width"

Python dictionary

To just set the custom property values, use a Python dictionary for the customProperties parameter that contains name value pairs.

To create custom properties, use a Python dictionary for the customProperties parameter that contains name definition pairs. The custom property definition is a Python list that contains the settings. The order of the setting must be data type, value, description, units, production visible and required. Optionally, the production visible and required can be left out. If they are left out the default values of production visible = true and required = false will be used.

Syntax

setCustomPropertyValues(customProperties)

  • Parameters

PyDictionary customProperties - A Python dictionary containing custom property path (name) definition pairs.

  • Returns

Nothing

  • Scope

All

Code Examples
Code Snippet
#Load a material lot MES object
obj = system.mes.loadMESObject('0000000031', 'MaterialLot')
 
#Build the definition of the custom properties to add
current_dataType = 'Float8'
current = 3.2
current_desc = 'Test results - current'
current_units = 'Amps'
 
volts_dataType = 'Float8'
volts= 12.0
volts_desc = 'Test results - current'
volts_units = 'Volts'
lotCP = {'Amps' : [current_dataType , current, current_desc , current_units], 'Volts': [volts_dataType , volts, volts_desc, volts_units]}
print lotCP
 
#Add the custom properties to the material lot MES object
obj.setCustomPropertyValues(lotCP)
 
#Remember to save the MES object
system.mes.saveMESObject(obj)
Output
{'Amps': ['Float8', 3.2, 'Test results - current', 'Amps'], 'Volts': ['Float8', 12.0, 'Test results - volts', 'Volts']}
Code Snippet
#Copy custom properties from one MES object to another
#Load a material lot MES object to copy custom properties values from
obj1 = system.mes.loadMESObject('0000000031', 'MaterialLot')
 
#Read the custom properties
cp = obj1.getCustomPropertiesFull()
print cp
 
#Load a material lot MES object to copy custom properties to
obj2 = system.mes.loadMESObject('0000000030', 'MaterialLot')
 
#Add the custom properties
obj2.setCustomPropertyValues(cp)
 
#Change the values of the custom properties
current = 3.4
volts = 11.9
obj2.setPropertyValue('Amps', str(current))
obj2.setPropertyValue('Volts', str(volts))
 
#Remember to save the MES object
system.mes.saveMESObject(obj2)
Output
{u'Amps': [u'Float8', u'3.2', u'Test results - current', u'Amps', True, False], u'Volts': [u'Float8', u'12.0', u'Test results - volts', u'Volts', True, False]}{u'Amps': 3.4, u'Volts': 11.9}
Code Snippet
#Load a response segment MES object
segObj = system.mes.loadMESObject('8163976b-1333-4aa2-9f76-e622ef1b5174')
 
#Build the custom property definitions
weight = 25
length = 152
cp = {'Weight': ['Int4', weight], 'Length': ['Int4', length]}
 
#Add the custom properties to the Pencil material reference
segObj.setCustomPropertyValues('ResponseMaterial', 'Pencil', cp)  

print segObj.getCustomPropertyValues('ResponseMaterial', 'Pencil')
 
#Remember to save the MES object
system.mes.saveMESObject(segObj)
Output
{u'ResponseMaterial.Pencil.Weight': 25, u'ResponseMaterial.Pencil.Length': 152}
Description

Set the enabled state of the MES object. By using this script function with parameter of False will delete the MES object. After setting the enabled state to false, the object must be saved for the changes to take effect. At the time the disabled MES object is saved, the name is also modified. This allows for the name to be reused in the future without naming conflicts.

The Enterprise MES Object (your top level in the Production Model) cannot be deleted. It can only be edited.

Syntax

setEnabled(enable)


  • Parameters

boolean enable - The new enabled state to make the MES object.

  • Returns

Nothing

  • Scope

All

Code Examples
Code Snippet
#Disable MES object example
#Load the MES object
obj = system.mes.loadMESObject('Box', 'MaterialDef')
print "Name of enabled MES object: %s" % obj.getName()
 
#Disable the MES object and save it
obj.setEnabled(False)
system.mes.saveMESObject(obj)
Output
Name of enabled MES object: Box
Code Snippet
#Enable MES object example
#Load the disabled MES object
obj = system.mes.loadDisabledMESObject('Box', 'MaterialDef')
print "Name of disabled MES object: %s" % obj.getName()
 
#Disable the MES object and save it
obj.setEnabled(True)
system.mes.saveMESObject(obj)
Output
Name of disabled MES object: Box{9320}
Description

Set a property value of an MES object by name or path. The property can be a core property, custom property or complex property of the MES object. In the case where custom properties are nested, a path is required to set the correct value.

The property value is passed as a String, but is converted to the correct data type for the property.

Syntax

setPropertyValue(propertyPath, value)


  • Parameters

String propertyPath - The name or path of the property being written to.

String value - The value to set the property to.

  • Returns

Nothing

  • Scope

All

Code Examples
Code Snippet
#Load a MES object
obj = system.mes.loadMESObject('Box', 'MaterialDef')
 
#Get and print the values before changing them
width = obj.getPropertyValue('Dimension.Width')
height = obj.getPropertyValue('Dimension.Height')
print "Values before setPropertyValue is called: Width = %d, Height = %d" % (width, height)
 
#Set the properties to new values
width = 14
height = 24
obj.setPropertyValue('Dimension.Width', str(width))
obj.setPropertyValue('Dimension.Height', str(height))
 
#Don't forget to save the MES object after changing property values
system.mes.saveMESObject(obj)

#Get and print the new values of the properties
width = obj.getPropertyValue('Dimension.Width')
height = obj.getPropertyValue('Dimension.Height')
print "Values after setPropertyValue is called: Width = %d, Height = %d" % (width, height)
Output
Values before setPropertyValue is called: Width = 10, Height = 12
Values after setPropertyValue is called: Width = 14, Height = 24
Code Snippet
#Rename MES object example
#Load a MES object
obj = system.mes.loadMESObject('Box', 'MaterialDef')
 
#Get and print the current name of the MES object
#Notice either method can be used to read the Name property
print obj.getName()
print obj.getPropertyValue('Name')
 
#Change the name of the MES object
obj.setPropertyValue('Name', 'Empty Box')

#Don't forget to save the MES object after changing property values
system.mes.saveMESObject(obj)



Object Events

This object inherits the AbstractMESObject events...

Objects have events associated with them that allow for custom scripts to be added whenever the event occurs. Refer to Object Events for more information.

 

'New' Event

This event is run every time a new MES object is created. It can be used to add custom properties or to perform other tasks.

If no script is entered, then the default handler will be executed. To execute the default handler from within the script entered here, add a script line:

Code Snippet
#Add custom property when a new instance of a MaterialDef object is created.
obj = event.getMESObject()
obj.addCustomProperty('Width', 'Int4', 'Part Width', 'mm', True, False)
event.runDefaultHandler()

  • No labels