Basic Shape: Part functions

If the property Model is set to 5 meaning it is using a custom shape, your can use the following functions to get/set parts visibility and colors.

Here are the available functions:

SetPartVisible

void SetPartVisible(partIndex: Number, visible: boolean);

Parameters

Name Type Description
partIndex Number The index of the part
visible Boolean The new visibility state

Return Value

None

Example

var bs1 = GetComponentByNameAndType("BS1", "Basic Shape");
bs1.SetPartVisible(3, false); // Hide part 3

GetPartVisible

boolean GetPartVisible(partIndex: Number);

Parameters

Name Type Description
partIndex Number The index of the part

Return Value

The current visibility state of this part

Example

var bs1 = GetComponentByNameAndType("BS1", "Basic Shape");
var state = bs1.GetPartVisible(3); 
LogDebug(`Part 3 visibility = ${state}`);

SetPartColor

void SetPartColor(partIndex: Number, colorName: String);

Parameters

Name Type Description
partIndex Number The index of the part
colorName String The name of the color for this part

Return Value

None

Example

var bs1 = GetComponentByNameAndType("BS1", "Basic Shape");
bs1.SetPartColor(3, "Sym3 Blue"); // set part 3 to be blue

GetPartColor

String GetPartColor(partIndex: Number);

Parameters

Name Type Description
partIndex Number The index of the part

Return Value

The name of the color for this part.

Example

var bs1 = GetComponentByNameAndType("BS1", "Basic Shape");
var color = bs1.GetPartColor(3); 
LogDebug(`Part 3 color = ${color}`);