Skip to main content

Material

Sample Plugin Importing U3M Exporting U3M Getting Material by id Deleting a Material Cloning a Material Updating a Material Material Mat...

Updated over 2 months ago

Material

Materials are fabrics, seams, artworks or trims on a garment. Use the Material API to add new material, set material physics, remove materials, and so on.

For more information about the feature, please visit here.

To learn more about the rest of the API, please refer to Material in the repository.

Sample Plugin

Sample plugin for Materials is available here

Importing U3M

Code Snippet

Python C++ C#

Python

garment_id = BwApi.GarmentId()
colorwayId = BwApi.ColorwayCurrentGet(garment_id )
full_path = '<path to the u3m>'
material_ids = MaterialImport(garmentId, colorwayId, fullPath)

C++

BwString garmentId;
BwApiGarmentId(garmentId);
int colorwayId;
BwApiColorwayCurrentGet(BwApiStringGet(garmentId), &colorwayId);
BwApiVectorInt* materialIds = BwApiVectorIntCreate();
BwApiMaterialImport(BwApiStringGet(garmentId), colorwayId, "<path to the u3m>", materialIds);

C#

string garmentId;
BwApi.GarmentId(out garmentId);
int colorwayId;
BwApi.ColorwayCurrentGet(garmentId, out colorwayId);
BwApiVectorInt materialIds = new BwApiVectorInt();
BwApi.MaterialImport(garmentId, colorwayId, "path to the u3m", materialIds);

Result

import-u3m.png

Exporting U3M

Code Snippet

Python C++ C#

Python

garment_id = BwApi.GarmentId()
colorwayId = BwApi.ColorwayCurrentGet(garment_id )
full_path = '<path to export the u3m>'
MaterialExport(garmentId, colorwayId, 1, fullPath)

C++

BwString garmentId;
BwApiGarmentId(garmentId);
int colorwayId;
BwApiColorwayCurrentGet(BwApiStringGet(garmentId), &colorwayId);
BwApiVectorInt* materialIds = BwApiVectorIntCreate();
BwApiMaterialExport(BwApiStringGet(garmentId), colorwayId, 1, "<path to export the u3m>")

C#

string garmentId;
BwApi.GarmentId(out garmentId);
int colorwayId;
BwApi.ColorwayCurrentGet(garmentId, out colorwayId);
BwApiVectorInt materialIds = new BwApiVectorInt();
BwApi.MaterialExport(garmentId, colorwayId, 1, "path to export the u3m")

Getting Material by id

Code Snippet

Python C++ C#

Python

# get existing material as json string object
materialJson = BwApi.MaterialGet(garmentId, colorwayId, materialId)

C++

// get existing material as json string object
BwString materialJson;
BwApiMaterialGet(garmentId, colorwayId, materialId, materialJson);

C#

// get existing material as json string object
BwApiString materialJson = new BwApiString();
BwApi.MaterialGet(garmentId, colorwayId, materialId, out materialJson);

Result

material json object as a string containing all the material's information. see schema

Deleting a Material

Code Snippet

The code snippet below shows how to delete an existing material.

Python C++ C#

Python

# delete an existing material
BwApi.MaterialDelete(garmentId, colorwayId, materialId)

C++

// delete an existing material
BwApiMaterialDelete(garmentId, colorwayId, materialId);

C#

// delete an existing material
BwApi.MaterialDelete(garmentId, colorwayId, materialId);

Result

delete-u3m.png

Cloning a Material

Code Snippet

The code snippet below shows how to clone an existing material to any colorway.

Python C++ C#

Python

# clone an existing material
newMaterialId = BwApi.MaterialClone(garmentId, colorwayId, materialId, destColorwayId)

C++

// clone an existing material
int newMaterialId;
BwApiMaterialClone(garmentId, colorwayId, materialId, destColorwayId, &newMaterialId);

C#

// clone an existing material
int newMaterialId;
BwApi.MaterialClone(garmentId, colorwayId, materialId, destColorwayId, out newMaterialId);

Result

clone-material.png

Updating a Material

Code Snippet

Python C++ C#

Python

# update an existing material
# assuming materialJson contains the above material
BwApi.MaterialUpdate(garmentId, colorwayId, materialId, materialJson)

C++

// update an existing material
// assuming materialJson contains the above material
BwApiMaterialUpdate(garmentId, colorwayId, materialId, materialJson);

C#

// update an existing material
// assuming materialJson contains the above material
BwApi.MaterialUpdate(garmentId, colorwayId, materialId, materialJson);
Did this answer your question?