Search code examples
anylogic

shapeBody.setFillColor not working (from Anylogic in 3 days book)


So I am following along with the example Market model in the "Anylogic in 3 days" eBook.

It says to create a state and set the On Enter action to this:

shapeBody.setFillColor(lavender);

All I get is this:

Description: shapeBody cannot be resolved. Location: Market/Consumer/PotentialUser - State

I have tried:

person.setFillColor(lavender);

but then I just get:

Description: The method setFillColor(Color) is undefined for the type Shape3DObject. Location: Market/Consumer/User - State

Solution

  • From the sequence of errors, I am guessing your mistake is that you are using the 3D shape person and not the 2D one (left vs. right in the below picture).

    enter image description here

    Anyway, the 2D shape (black icon) is a group of shapes. If you click on it twice (wait between the two clicks), you will see that a shape within the group called "ShapeBody" is selected. This is what the book's function is accessing.