question

Daniel R13 avatar image
0 Likes"
Daniel R13 asked Daniel R13 commented

Iterate Over All People Objects in PersonLabels Table

Hi Team!

Using FlexScript I am currently trying to get a list of all the people in the People Statistics Table -> Person -> PersonLabels table. The primary goal is to iterate over all of these people in order to get there x, y, z locations. Any ideas? Thanks!

-Dan

FlexSim 21.1.2
flexscriptflexsim 21.1.2locationpersonpeople statistics table
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

Jordan Johnson avatar image
3 Likes"
Jordan Johnson answered Daniel R13 commented

I would not use the PersonLabels table for that task. It includes people that have left the model.

I would probably make a Group in the toolbox, and then, right after your Create Person activity, I would add them to that group, using a Custom Code activity with code like this:

Group("MyGroup").addMember(token.Person)

The nice thing about groups is when the person is removed from the model, they will also be removed from the group.

Then you can loop over the group:

Group people = Group("MyGroup");
for (int i = 1; i <= people.length; i++) {
  Object person = people[i];
  Vec3 location = person.location.project(person.up, model());
  // do something with location
}

The reason for the call to .project() is because the person might be in a location, and when they are, their position is relative to the location, not to the overall model.

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

Daniel R13 avatar image Daniel R13 commented ·

Thank you very much!

0 Likes 0 ·