How to put model entities into a group using Python API?

Dear Sim4life Team,
I have created an EntityGroup and some entities using Python API scripter, but I don't know how to put these entities into this EntityGroup using Python API. Could you help me answer this question?

Thank you!
Mingjuan Ma

Something like this

my_group = s4l.model.CreateGroup()
my_poly = s4l.model.CreatePolyLine(my_points)

Hello @montanaro,

What if I already created a group? How can I get that folder to add more items to it?


group_name = "Group 1"

entities = s4l.model.AllEntities()
my_group = entities[group_name]

You can use this to get any element in your model, HOWEVER, unfortunately you'll run into problems if you have multiple model elements / groups with the same name, so make sure to have unique names for every top level element (don't worry about elements within groups)

Thanks @montanaro!