Skip to content
  • Search
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse

ZMT zurich med tech

  1. Home
  2. Sim4Life
  3. Python API
  4. How to put model entities into a group using Python API?

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

Scheduled Pinned Locked Moved Python API
5 Posts 3 Posters 2.1k Views 4 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mingjuan
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • M Offline
      M Offline
      montanaro
      wrote on last edited by
      #2

      Something like this

      my_group = s4l.model.CreateGroup()
      my_poly = s4l.model.CreatePolyLine(my_points)
      my_group.Add(my_poly)
      
      1 Reply Last reply
      0
      • M Offline
        M Offline
        mkn
        wrote on last edited by
        #3

        Hello @montanaro,

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

        Thanks!

        1 Reply Last reply
        0
        • M Offline
          M Offline
          montanaro
          wrote on last edited by montanaro
          #4
          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)

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mkn
            wrote on last edited by
            #5

            Thanks @montanaro!

            1 Reply Last reply
            0

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Search