Skip to main content

system.mes.material.getPropertyOrCreateNew

Description

Retrieves a Material Properties record if an existing material property exists with the specified ID or name. Otherwise, creates a new Material Properties record with the specified name and attributes.

Syntax

system.mes.material.getPropertyOrCreateNew(**property_data)

Parameters

ParameterTypeNullableDescription
materialClassIdString (ULID)FalseThe ULID of the material class associated with this material property.
nameStringFalseThe name of the material property.
descriptionStringTrueA description of the material property.
dataTypeStringFalseThe data type of the property (e.g., Integer, String, Float). Default value is String.
lowLimitDoubleTrueThe minimum value allowed for a numerical property.
highLimitDoubleTrueThe maximum value allowed for a numerical property.
formatStringTrueThe format of the property, if applicable.
unitOfMeasureIdString (ULID)TrueThe ULID of the unit of measure for this property.
unitOfMeasureNameStringTrueThe name of the unit of measure for the property. For display purposes only.
unitOfMeasureSymbolStringTrueThe symbol of the unit of measure for the property. For display purposes only.
optionsStringTrueList of possible values for the property (e.g., "[option1, option2]").
nullableBooleanFalseDefines if the property can accept null values. Default value is false.
defaultValueMixedTrueThe default value assigned to the property if none is provided. The type is mixed as it depends on what dataType is.
idString (ULID)TrueThe ULID of the material property (optional, for updating an existing property).
notesStringTrueNotes related to the material property.
enabledBooleanFalseIndicates if the property is active and enabled. Default value is true.
spare1StringTrueAdditional field for user-defined context.
spare2StringTrueAdditional field for user-defined context.
spare3StringTrueAdditional field for user-defined context.

Returns

Returns a JSON representation of the material property.

Code Examples

# Generate the object structure for a new property object for temperature
new_property = system.mes.material.newProperty()

# Define property details
new_property['name'] = 'Temperature'
new_property['dataType'] = 'Float'
new_property['unitOfMeasureId'] = '01JAP8RJBN-4VYZUKE1-LY2QHV8X'
new_property['nullable'] = False
new_property['lowLimit'] = -20
new_property['highLimit'] = 50
# (You can continue setting other properties as needed here)

# Get the property if it exists, otherwise creates it with the given attributes
property = system.mes.location.getPropertyOrCreateNew(**new_property)

# Output the JSON representation of the property
print(property)