How do I export pictures for multiple design points?

Pierre Thieffry
Pierre Thieffry Member, Moderator, Employee Posts: 83
25 Answers 10 Comments 25 Likes Ansys Employee
edited June 21 in Structures

I am running a simulation for which I create figures for various results. I want to export them for each design point. How can I do this?

Comments

  • Pierre Thieffry
    Pierre Thieffry Member, Moderator, Employee Posts: 83
    25 Answers 10 Comments 25 Likes Ansys Employee

    Here's a sample code to use in a Python Code object. For this to work, you will have to use version 23.1 and above as picture export in batch mode did not work in earlier versions.

    Small bonus: you'll see how to retrieve the design point number and the user_files folder without the need for executing a script at project page level.


    def after_post(this, solution):# Do not edit this line
      """
      Called after post processing.
      Keyword Arguments : 
        this -- the datamodel object instance of the python code object you are currently editing in the tree
        solution -- Solution
      """
    
    
      figures=ExtAPI.DataModel.GetObjectsByType(DataModelObjectCategory.Figure)
       
       
      import os
      cmd = 'returnValue(GetUserFilesDirectory())'
       
      wd=this.Parent.Parent.WorkingDir
      dp=wd.split('\\')[-4]
      user_dir=os.path.join(wd,'..\\..\\..\\user_files')
       
      for fig in figures:
    
         
        ExtAPI.DataModel.Tree.Activate(fig)
        filename=user_dir+'\\'+'Figure - '+fig.Parent.Name+'_'+dp+'.jpg'
        ExtAPI.Graphics.ExportImage(filename)
    


  • Dima
    Dima Member Posts: 1
    Name Dropper First Comment

    Hello @Pierre Thieffry ,

    thank you for the post, it is really helpful!

    I am trying to do some modifications on the legend text, to increase it.

    I've tried something like this based on the documentation which I found on the web, but it is not working:

    ExtAPI.Graphics.ExportImage(filename,  GraphicsImageExportFormat('png'), GraphicsImageExportSettings.FontMagnification(1.3))


    Can you help me please with this ?