question

Choi Hyun Woong avatar image
0 Likes"
Choi Hyun Woong asked Choi Hyun Woong edited

How to use TASKTYPE_STARTANIMATION

As always, thank you for your support!

I am trying to assign a task with a loading animation to a TaskExcuter through the TaskSequence.addTask() method.

Also, TaskExcuter has custom animation applied through Animation Creator.

I want to load the items after the TaskExcuter moves to the destination (10,0,0) and performs a custom animation.


TaskSequence ts = TaskSequence.create(Model.find("TaskExcuter1"), 0, 0);

ts.addTask(TASKTYPE_TRAVELTOLOC, NULL, NULL, 10, 0 , 0);

ts.addTask(TASKTYPE_STARTANIMATION, NULL, NULL, 1);

ts.addTask(TASKTYPE_LOAD, item, station, 1);

ts.dispatch();


When you run the code above, the TaskExcuter moves to the destination (10,0,0), starts the custom animation, and loads the item even though the animation has not ended.


Additionally, please check the durationtype parameter and durationtvalue parameter, which are the arguments of TASKTYPE_STARTANIMATION.

FlexSim 24.1.0
tasksequencestasktype
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

Felix Möhlmann avatar image
0 Likes"
Felix Möhlmann answered Choi Hyun Woong edited

The task only starts the animation. It is finished in an instant. If you want to wait until the animation has finished, add a delay task with time equal to the animation duration to the task sequence.

For more information about the speed and duration parameters see the documentation on the Animation class.

https://docs.flexsim.com/en/24.0/Reference/CodingInFlexSim/FlexScriptAPIReference/Data/Animation.html#Method-start

· 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.

Choi Hyun Woong avatar image Choi Hyun Woong commented ·

Thank you for reply.

How do I change the code that was written?

Are durationType and speedType parameter the same? Please write explicitly.


---------------------------------------------------------------------


TaskSequence ts = TaskSequence.create(Model.find("TaskExcuter1"), 0, 0);

ts.addTask(TASKTYPE_TRAVELTOLOC, NULL, NULL, 10, 0 , 0);

ts.addTask(TASKTYPE_STARTANIMATION, NULL, NULL, 1);

ts.addTask(TASKTYPE_LOAD, item, station, 1);

ts.dispatch();

0 Likes 0 ·
Joerg Vogel avatar image Joerg Vogel Choi Hyun Woong commented ·

@Choi Hyun Woong, sure, you shown in your presented code a higher level of knowledge and Felix described it good enough to do it on your own from there.

..
ts.addTask(TASKTYPE_STARTANIMATION, NULL, NULL, 1);
ts.addTask(TASKTYPE_DELAY, NULL, NULL, timevar, statevar);
ts.addTask(TASKTYPE_LOAD, item, station, 1);
..

You need to assign to local variables timevar and statevar suitable values. timevar gets a value of animation properties, which is how long this animation takes.

You can test value behaviors in small models on your own. This is what I do to get sufficient results.

0 Likes 0 ·
Choi Hyun Woong avatar image Choi Hyun Woong Joerg Vogel commented ·

Thank you for reply.

The code you suggested loads after the custom animation ends.

I am curious about the var2 and var3 parameters of TASKTYPE_STARTANIMATION.

Additionally, can't the TASKTYPE_STARTANIMATION method delay while an animation is being performed?

https://docs.flexsim.com/en/23.2/Reference/TaskSequences/TaskTypes/TaskTypes.html#startAnimation

0 Likes 0 ·
Show more comments