code: public static Location getObjectLocation(ShanksSimulation simulation,
              PercipientShanksAgent agent, Object object) {
          try {
              if (agent.getCurrentLocation().is3DLocation()) {
                  ContinuousPortrayal3D devicesPortrayal;
                  devicesPortrayal = (ContinuousPortrayal3D) simulation
                          .getScenarioPortrayal().getPortrayals()
                          .get(Scenario3DPortrayal.MAIN_DISPLAY_ID)
                          .get(ScenarioPortrayal.DEVICES_PORTRAYAL);
                  Continuous3D devicesField = (Continuous3D) devicesPortrayal
                          .getField();
                  Double3D loc = devicesField.getObjectLocation(object);
                  return new Location(loc);
              } else if (agent.getCurrentLocation().is2DLocation()) {
                  ContinuousPortrayal2D devicesPortrayal = (ContinuousPortrayal2D) simulation
                          .getScenarioPortrayal().getPortrayals()
                          .get(Scenario2DPortrayal.MAIN_DISPLAY_ID)
                          .get(ScenarioPortrayal.DEVICES_PORTRAYAL);
                  Continuous2D devicesField = (Continuous2D) devicesPortrayal
                          .getField();
                  Double2D loc = devicesField.getObjectLocation(object);
                  return new Location(loc);
              }
          } catch (DuplicatedPortrayalIDException e) {
              e.printStackTrace();
          } catch (ScenarioNotFoundException e) {
              e.printStackTrace();
          } catch (ShanksException e) {
              e.printStackTrace();
          }
          return null;
  
      }
docs: Get the location of an object in the simulation
  
  @param object
  @return the Location object that represent the position of the object