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

Landon Mitchell Kanner
Landon Mitchell Kanner Member, Employee, GitHub-issue-creator Posts: 327
50 Answers 100 Comments Second Anniversary 25 Likes
✭✭✭✭
edited June 2023 in Structures

Comments

  • Landon Mitchell Kanner
    Landon Mitchell Kanner Member, Employee, GitHub-issue-creator Posts: 327
    50 Answers 100 Comments Second Anniversary 25 Likes
    ✭✭✭✭
    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
    Name Dropper First Comment
    **

    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, GitHub-issue-creator Posts: 327
    50 Answers 100 Comments Second Anniversary 25 Likes
    ✭✭✭✭
    edited May 2024

    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)