Skip to main content

system.mes.material.saveMaterialClass

Description

Creates or updates a Material Classes record in the system based on the provided parameters.

Syntax

system.mes.material.saveMaterialClass(**material_class_data)

Parameters

ParameterTypeDescription
nameStringThe name of the material class.
descriptionStringThe description of the material class.
pathStringThe path to the material class.
parentIdString (ULID)The ULID of the parent material class to this material class.
idString (ULID)The ULID of the material class (optional, used for updating an existing material class).
notesStringNotes related to the material class.
enabledBooleanIndicates if the material class is active and enabled.
spare1StringAdditional field for user-defined context.
spare2StringAdditional field for user-defined context.
spare3StringAdditional field for user-defined context.

Returns

Returns a JSON representation of the saved material class.

Code Examples

# Generate the object structure for a new material class object, set the initial arguments and save it
new_material_class = system.mes.material.newMaterialClass()
new_material_class['name'] = 'RAW'
saved_material_class = system.mes.material.saveMaterialClass(**new_material_class)

# Output the JSON representation of the saved material class
print(saved_material_class)

# Generate the object structure for another new material class to update the previous material class
material_class_data = system.mes.material.newMaterialClass()

# Set basic attributes for the updated material class
material_class_data['id'] = saved_material_class.id
material_class_data['name'] = 'RAW'
material_class_data['description'] = 'Material Class for Raw Materials'
# (You can continue setting other properties as needed here)

# Save the material class to update it in the system
updated_material_class = system.mes.material.saveMaterialClass(**material_class_data)

# Output the JSON representation of the updated material class
print(updated_material_class)