Using Mechanical Scripting, how can I export images of results?

Landon Mitchell Kanner
Landon Mitchell Kanner Member, Employee Posts: 290
100 Comments 25 Answers 25 Likes Photogenic
✭✭✭✭
edited June 2023 in Structures

Comments

  • Landon Mitchell Kanner
    Landon Mitchell Kanner Member, Employee Posts: 290
    100 Comments 25 Answers 25 Likes Photogenic
    ✭✭✭✭
    for analysis in ExtAPI.DataModel.AnalysisList:
        analysisName = analysis.Name
        solution = analysis.Solution
        for child in solution.Children:
            childName = child.Name +"_"+ analysisName
            child.Activate()
            imagePath = "D:/{}.png".format(childName) 
            ExtAPI.Graphics.ExportImage(imagePath)
    


  • prasadmsonar_123
    prasadmsonar_123 Member Posts: 2
    First Comment Name Dropper
    **

    Hello @Landon Mitchell Kanner , Thanks for sharing this.
    How to save these results in working directory?
    Lets say we have defined working directory as dirName = ExtAPI.DataModel.Project.Model.Analyses[0].WorkingDir

  • Landon Mitchell Kanner
    Landon Mitchell Kanner Member, Employee Posts: 290
    100 Comments 25 Answers 25 Likes Photogenic
    ✭✭✭✭
    edited May 29

    Haven't tested it, but it would be something like:

    import os
    
    for analysis in ExtAPI.DataModel.AnalysisList:
        dirName = analysis.WorkingDir
        analysisName = analysis.Name
        solution = analysis.Solution
        for child in solution.Children:
            childName = child.Name +"_"+ analysisName
            child.Activate()
            imageName = "{}.png".format(childName) 
            imagePath = os.path.join(dirName,imageName)
            ExtAPI.Graphics.ExportImage(imagePath)