How can I get the name of the analysis block that my python code object is running in?

I am using a python code object under solution to postprocess results. I need to access the name of the analysis block the current script is in. I need the workflow to work without the Mechanical GUI (working in batch from workbench).
Best Answer
-
To do this, you can look for the System ID of the current system your code is in following the method described in this post:
How can I get the workbench level system ID of an analysis system from code inside Mechanical ACT?Instead of
analysis = ExtAPI.DataModel.AnalysisList[1]
You can use:
analysis = this.Parent.Parent
since you are working in a python code under solution. Hence, you will not have to select manually from the analysis list.
Then, inject the retrieved ID in Workbench scripting to search for the corresponding system and retrieve its name. You can use the methods described in this post:
How to get a Workbench system name inside a Python Code object while Mechanical is in batch mode?0