Skip to content
  • Search
Skins
  • Light
  • 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. cant assign entities

cant assign entities

Scheduled Pinned Locked Moved Python API
modelingentities
3 Posts 2 Posters 570 Views
  • 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
    michaelsch
    wrote on last edited by michaelsch
    #1

    Hello
    I load some model and try to assign entities but get errors :

    Mesh2    = s4l.model.Import(r'C:\sintetic data\bones.stl')
    

    see value in python :
    Mesh2
    (<XCoreModeling.TriangleMesh object at 0x000002199E6FA5B0>,)

    so now try to put entity

    entities = model.AllEntities()
    Mesh2 = entities['Mesh2']
    

    and get this error

    File "<string>", line 1, in <module>
    File "C:\Program Files\Sim4Life_7.0.1.8169\Python\lib\site-packages\s4l_v1\model__model_impl.py", line 167, in getitem
    raise KeyError("%s key is missing" % key)
    KeyError: 'Mesh2 key is missing'

    i tried to put name but no success

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

      Can't test at the moment but i'd suggest assigning a name yourself with Mesh2.Name = "Mesh 2" and make sure the name is unique.

      If this still isn't helpful I'd suggest to iterate over entitites and print the names to see what it comes up as:

      entities = model.AllEntities()
      for e in entities:
          print(e.Name)
      
      1 Reply Last reply
      1
      • M Offline
        M Offline
        michaelsch
        wrote on last edited by
        #3

        really thanks this is direction of solution
        what i did with friend

        1. Mesh2 = s4l.model.Import(r'C:\sintetic data\bones.stl')[0]
          so now Mesh2 is not tuple and has its own name bones
        2. meanwhile i write all in one script without functions so i dont need realy the entities as in the example of 2 plates supplied with sim4life ...
        1 Reply Last reply
        0
        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