General Mechanical

General Mechanical

Scripting in Ansys Workbench

    • Oussama Hajjaj
      Subscriber

      I wrote a script to rename the mechanical analyses according to their name in WB, but the problem is that if the analyses share the same model, they will have the same name as the last one in WB. the code is written in the script editor on Workbench.

      cmd="""
      for analysis in Model.Analyses:
          analysis.Name='noname'
          """
      oldname='noname'
      systems=GetAllSystems()
      for sys in systems:
          try: 
              model= sys.GetContainer(ComponentName="Model")
              newname=sys.DisplayText
              cmd=cmd.replace(oldname,newname)
              model.SendCommand(Language="Python",Command=cmd)
              oldname=newname
          except:
              pass

    • Aniket
      Ansys Employee

      So do you want to rename systems in Mechanical as per their name in Workbench system? From your script it looks like you are assigning 'noname' string to every system in Mechanical.

      -Aniket

      How to access Ansys help links

      Guidelines for Posting on Ansys Learning Forum

       

    • Oussama Hajjaj
      Subscriber

      Hello , yes it's for my internship and my supervisor asked me to make a script to rename systems in Mechanical as per their name in Workbench system. 

      I want ton change it and have some help , noname is the oldname , when using the commands after, i can change it to a newname. i should make the first for loop over a list but in my case it's just over one name of the list and i don't know how to solve it .

       

       

Viewing 2 reply threads
  • You must be logged in to reply to this topic.