question

Aaron C avatar image
0 Likes"
Aaron C asked Ben Wilson commented

How can I add a collision sphere to spawned Person Flow Item?

I have a model that will spawn numerous Person flow items. I need to be able to detect when they get within a certain distance from each other. For this, I want to add a collision sphere to them upon their creation. I assign the Person to token.Person and have tried the following code, but drawspheres() is throwing all kinds of exceptions at me, and not sure what else to try, as I feel like I've followed the documentation. I've also tried just adding a sphere to a generic shape in the scene just for testing, but no luck there either.

Object person = token.Person;
Object view = views().find("active>Documents/Perspective/1+/~");
// Have also tried: Object view = sv();   after designating the 3D view
addsphere(person, 0.0, 0.0, 0.0, 6);
drawspheres(person, view);
FlexSim 19.1.2
flexsim 19.1.2flowitemscollisioncollision avoidance
· 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.

Ben Wilson avatar image Ben Wilson ♦♦ commented ·

Hi @aaron.c, was logan.gold's answer helpful? If so, please click the red "Accept" button on their answer. Or if you still have questions, add a comment and we'll continue the conversation.

0 Likes 0 ·

1 Answer

Logan Gold avatar image
1 Like"
Logan Gold answered

Instead of using the drawspheres() command, you can try to set the variable in the new Person flowitem instead:

Object person = token.Person;
addsphere(person, 0.0, 0.0, 0.0, 6);
setvarnum(person, "drawcollspheres", 1);

This is the same variable that gets set when you set the checkbox "Draw Spheres" in a Task Executer's Collision tab.

If you are trying to do this for a different type of flowitem (not a Person that has the same properties as an Operator), then I'll need to look a bit more into the drawspheres() command. It's not one that comes up very often.

I have also noticed that Person flowitems that are created during a model run don't always behave the same way as a Task Executer like an Operator. In fact, if you create a Person flowitem, then try to set up collision checks in its Properties window the same way you would an Operator, it doesn't seem to work as well as with an Operator. So there might be an issue with how Person flowitems are configured to begin with that make collision checks harder to set up. Again, I will look into this a bit more and see what is happening.

5 |100000

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