When the user selects “solve” the python script will:
Find out what macro file has been selected
Display a message to the Solver Script Output if more than one attribute group is defined
Obtain selected upstream solution data
Display a message to the Solver Script Output if more than one upstream system is entered
Run the macro with Mechanical APDL
It is assumed that the macro will write data out to a CSV file so it can be read at the evaluate stage
Display the output from running the macro as the Solver Output
import os
DA = DesignAssessment
def runDADemoSolve():
#1.a - display message
if DA.AttributeGroupCount != 1:
print "Only one Attribute Group should be entered"
#2.a - Display message
if DA.SolutionSelections()[0].SolutionCount != 1:
print "Only one upstream solution should be entered"
#1 - Get the macro path
MAPDLMacro = DA.AttributeGroups()[0].Attribute("MAPDL Macro File").ValueAsString
SolPath = DA.SolutionSelections()[0].SolutionByRow(1).ResultFilePath
#2 - Form the command line strings
SolPath_Output = "Macro.out"
SolTime_ARG2 = str(DA.SolutionSelections()[0].SolutionByRow(1).Time)
BatchArgs = " -par1 file -par2 " + SolTime_ARG2
#2 - Run the solve with MAPDL
#Change to the path where the results are kept
os.chdir(SolPath.rstrip('file.rst'))
#Run MAPDL
DA.Helper.RunMAPDL(MAPDLMacro,SolPath_Output,BatchArgs)
#2.b - Display the output
DA.Helper.ReplaceSolverOutputFile(SolPath_Output)
runDADemoSolve()