question

Sri_vikas K avatar image
0 Likes"
Sri_vikas K asked Joerg Vogel edited

Code lines for doing animation.

Hi Cammunity.

In my model i am using a code to make an object run an animation.

if (buttonNum == 8)

{

Model.find("Door");

}

if (buttonNum == 9)

{

Model.find("Door");

}

What is the complete code lines for this.

Thankyou

FlexSim 23.0.3
using code
· 1
5 |100000

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

Sri_vikas K avatar image Sri_vikas K commented ·

It is showing some error like this.error-in-code.png

0 Likes 0 ·
error-in-code.png (6.9 KiB)

1 Answer

·
Felix Möhlmann avatar image
2 Likes"
Felix Möhlmann answered Felix Möhlmann commented

In your screenshot you are mixing up two ways to access the animation.

You can either use the old commands (startanimation, stopanimation, ...) which you can look up in the command help within FlexSim directly (Help -> Command Helper).

1676112634526.png

Or you the newer "animations" class. Information about that is available in the class reference section of the online manual.

https://docs.flexsim.com/en/23.0/Reference/CodingInFlexSim/FlexScriptAPIReference/Data/Animation.html

If you need to look up syntax in general, those two sources will help you in most cases.


1676112634526.png (23.7 KiB)
· 3
5 |100000

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

Sri_vikas K avatar image Sri_vikas K commented ·

I have tried in that way also, but it is still showing the error.

error-window.png

0 Likes 0 ·
error-window.png (39.7 KiB)
Felix Möhlmann avatar image Felix Möhlmann Sri_vikas K commented ·
Try placing "as(Object)" after "Model.find()" like in the 7 an 11. This tells FlexSim what to interpret the node as.
0 Likes 0 ·
Joerg Vogel avatar image Joerg Vogel Felix Möhlmann commented ·

@Sri_vikas K, “find” method is of a flexscript class treenode. The class “animation” is a sub class of class Object. Felix showed a method of casting from one class to another class.

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.