anylogic

How to get X coordinate of crane bridge to put it in a variable in Anylogic


I use overhead crane in my model and I need to know position of its bridge (or hook - even better) during simulation - it is used in variable.

I tried func getBridgePosition(), but I dont understand how to get X coordinate from it. It has type "position" and cannot be read as any type of data. Also I tried craneBridge.getX() inside of my variable, but it shows only home position of bridge or is not updating during simulation. Function update() doesn't work with it as well.


Solution

  • getBridgePosition() returns a Position.

    In such cases, first read up on that in the help. Then, keep using code-complete to get what you need.

    In your case, getBridgePosition().getX()

    Same works for the hook but you need to specify the bridge: getHookPosition(OverheadCraneBridge bridge).getX()