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. import element inside a group using python

import element inside a group using python

Scheduled Pinned Locked Moved Python API
5 Posts 3 Posters 2.6k Views 3 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
    Micol
    wrote on last edited by
    #1

    Hello,

    I am trying to have an automated import of files in python.
    I need import an obj file directly inside a s4l group.
    I am able to do the action of importing and creating the group, separately, however I cannot move the elemt I imported inside the created group with python.
    Can you help me?

    Thank you

    1 Reply Last reply
    0
    • SylvainS Offline
      SylvainS Offline
      Sylvain
      ZMT
      wrote on last edited by
      #2

      Hello,
      Can you please explain what happens when you try to "move the element you imported inside the created group"?
      What error message do you get when you do something like:

      my_obj_list = s4l_v1.model.Import("my_file.sab")
      my_group = s4l_v1.model.CreateGroup()
      for my_obj in my_obj_list:
         my_group.Add(my_obj)
      
      1 Reply Last reply
      1
      • M Offline
        M Offline
        Micol
        wrote on last edited by
        #3

        Thank you, Indeed using this lines it works, thank you!
        Could I ask you, how can I save a matlab file with pyhon?
        When I do this, I only add the exporter but I can't save the file in my folder, I have to refresh the exporter manually

        Adding a new MatlabExporter

        inputs = [field_interpolation_filter.Outputs["EM E(x,y,z,f0)"]]
        matlab_exporter = analysis.exporters.MatlabExporter(inputs=inputs)
        	matlab_exporter.UpdateAttributes()
        document.AllAlgorithms.Add(matlab_exporter)
        

        Thank you for your help

        1 Reply Last reply
        1
        • H Offline
          H Offline
          halder
          ZMT
          wrote on last edited by
          #4

          Hi, add this: matlab_exporter.Update(overwrite = True)

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

            Thank you, I could obtain the same also using this:

            analysis.exporters.MatlabExporter.ExportTo(matlab_exporter,matlab_exporter.FileName)

            Do you think it is a good solution as well?

            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