system.mes.material.importFromJson
Description
Imports Materials from a JSON file provided as raw bytes. The service layer parses the JSON content and creates or updates material entities.
Recommended to export at least one pre-existing material to JSON using the Export Materials functionality to ensure the correct format of the JSON file.
Syntax
system.mes.material.importFromJson(importBytes)
Parameters
| Parameter | Type | Nullable | Description |
|---|---|---|---|
importBytes | PyArray | False | The JSON content as raw bytes. |
Returns
An ApiResponse object where data is the number of materials successfully imported or updated.
Code Examples
Here is an example of how to use the importFromJson method in the context of a Perspective File Upload Component
onFileReceived event handler. Reference Perspective - File Upload Scripting
for more information on the onFileReceived event handler.
def runAction(self, event):
jsonBytes = event.file.getBytes()
system.mes.material.importFromJson(jsonBytes)