question

Abhay Bajpai avatar image
0 Likes"
Abhay Bajpai asked Abhay Bajpai commented

Cannot assign an array to a label (Map) of a FlowItem

I started getting the following error:

FlexScript exception: Invalid variant type used with [] array operator at MODEL:/Tools/FlowItemBin>packing/PartPackingMethod c: MODEL:/StraightConveyor1/Product i: MODEL:/StraightConveyor1/Product/M1_FloorFrame_A1


1697833289798.png

This was caused because the array was not found in the 'PartLocMap' label of the flow item.

So I wrote the following script to override the 'PartLocMap' of every flow item out there when all the flow items were stored in "YARD". It works perfectly fine but when I would hit "Reset", everything goes back to what it originally said in the FlowItem Bin. This

The code i wrote:

treenode yard = Model.find("YARD");
var xyz = yard.subnodes.length;
Map partLocMap;
Array yard_storage_subnodes_arr = yard.subnodes.toArray();
//print(xyz);

for (int i=1; i <= yard.subnodes.length ; i++) {
Object Interested_Part = yard_storage_subnodes_arr[i].subnodes[1]; //gets Floor Frame part's partID.
print(Interested_Part);
partLocMap[Interested_Part.partID]=[Interested_Part.location,Interested_Part.rotation,Interested_Part.size];
}

for (int i=1; i <= yard.subnodes.length ; i++) {
yard.subnodes[i].partLocMap=partLocMap.clone();
}

ChampionHomes_V8_12.fsm
FlexSim 23.2.0
label update
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Jason Lightfoot avatar image
0 Likes"
Jason Lightfoot answered Abhay Bajpai commented

Where are you writing back to the flowitem bin?

You should refer to the script in the original model that did this. For example:

Object chassisFI=Model.find("/Tools/FlowItemBin/M1_Chassis_A/1");
Map partLocMap;
Array orientedParts=so().subnodes.toArray();
while (orientedParts.length){
    Object part=orientedParts.pop();
    partLocMap[part.partID]=[part.location,part.rotation];  
}
chassisFI.partLocMap=partLocMap.clone();

Here you can see the partLocMap is cloned to the flowitem in the bin.

· 5
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Abhay Bajpai avatar image Abhay Bajpai commented ·

Jason,

I thought i was writing the flow bin using this line in the code above:

yard.subnodes[i].partLocMap=partLocMap.clone();

I thought yard.subnodes[i] would loop through all the chassis that was being produced and would change it in the flow bin. Should I use the .so() instead?

0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦♦ Abhay Bajpai commented ·
Yard looks to be a container in your model.
0 Likes 0 ·
Abhay Bajpai avatar image Abhay Bajpai Jason Lightfoot ♦♦ commented ·

I see. I should rather ""/Tools/FlowItemBin/M1_Chassis_A/ "?

0 Likes 0 ·
Show more comments