question

Thomas JR avatar image
0 Likes"
Thomas JR asked Joerg Vogel commented

Invalid index in Model Tree

Hi everyone

I've been struggling with an error that shows up in the system console. The system console reads:

time: 31073.814080 exception: FlexScript exception: invalid index at MODEL:/Tools/People/Flows/InstancedFlows/Staff/Close?>variables/decision

The error always occurs within a "Release Staff" activity. The model seems to continue running smoothly despite the error, i.e. the tokens do actually release the staff and proceed correctly, however obviously it still bugs me that the error shows up.

I've checked the highlighted destination in the model tree. The following is the FlexScript code within the Custom code "decision":

/**Custom Code*/
Object current = param(1);
treenode activity = param(2);
Token token = param(3);
treenode processFlow = ownerobject(activity);
var pos = getvarnode(current, "resetposition").subnodes;
Vec3 returnPos = Vec3(pos[1].value, pos[2].value, pos[3].value);
Vec3 diff = returnPos - current.location;
if(diff.magnitude < current.size.x)
 return 1;

return 2;

My questions are as follows:

1) Is the functionality within said destination of the model tree generated by FlexSim itself?

2) Is the error caused by the param() function or Vec3()?

Note: I can't attach the model since it contains highly sensitive data. Therefore I accept the fact that my problem may not be solvable.

FlexSim 19.2.4
treerelease staffindex
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

·
Phil BoBo avatar image
1 Like"
Phil BoBo answered Joerg Vogel commented

1. Yes, that's the process flow used to control the Staff resources. That logic sends the staff back to their reset position when they are idle.

2. It looks like the error is with pos[1].value.

The "invalid index" might be that you don't have a pos[1] on the subnodes of the resetposition variable on the current object (1 is the "index").

Try setting the reset position on your object.


reset-pos.png (28.2 KiB)
· 2
5 |100000

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

Thomas JR avatar image Thomas JR commented ·

Ok, that makes sense, thanks. The weird thing is that the error suddenly disappeared yesterday. I deleted and re-added some 3D-objects and that may have solved the problem. However, if the problem re-appears then I will try out your solution.

Best regards

Thomas

1 Like 1 ·
Joerg Vogel avatar image Joerg Vogel commented ·

Perhaps you just need to tell, that the subnodes are an array:

var pos = getvarnode(current, "resetposition").subnodes;

to

var pos = getvarnode(current, "resetposition").subnodes.toArray();
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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