Path results vs time (Graphic control)
Erik Kostson
Member, Employee Posts: 233
✭✭✭✭
How can we get the tabular data (without using undocumented and supported commands) when the Graphics Control is set to time (not S).
0
Comments
-
One way is to loop over the times and get the max/min/average values and save them in a file.
model=ExtAPI.DataModel.Project.Model # refer to Model analysis = model.Analyses[0] solution = analysis.Solution ns=DataModel.GetObjectsByName('Selection')[0] # change as needed path = DataModel.GetObjectsByName('Path')[0] # change as needed res=solution.AddUserDefinedResult() res.ScopingMethod=GeometryDefineByType.Path res.Location=ns res.Location=path res.Expression='UZ' res.EvaluateAllResults() res.GraphControlsXAxis = GraphControlsXAxis.Time f1=open("D:\\testexppath.txt","w") #open file in user directory change as needed for t in time_steps: with Transaction(): res.DisplayTime=Quantity(float(t), "sec") max=res.Maximum min=res.Minimum ave=res.Average res.EvaluateAllResults() f1.write(str(t) + " , " + str(max) +","+ " , " + str(min) + "\n") f1.close()
another perhaps faster way is below (can be easily modified to save to a file - see last script):
myr=ExtAPI.DataModel.GetObjectsByName("User Defined Result") # name of results to activate Tree.Activate(myr) paneTabular=ExtAPI.UserInterface.GetPane(MechanicalPanelEnum.TabularData) control = paneTabular.ControlUnknown for col in range(1,control.ColumnsCount+1): for row in range(1,control.RowsCount+1): cellText= control.cell(row ,col ).Text if cellText!=None: print cellText
and saving to file:
myr=ExtAPI.DataModel.GetObjectsByName("User Defined Result") # name of results to activate Tree.Activate(myr) paneTabular=ExtAPI.UserInterface.GetPane(MechanicalPanelEnum.TabularData) control = paneTabular.ControlUnknown f1=open("D:\\testexppath2.txt","w") #open file in user directory change as needed for row in range(1,control.RowsCount+1): t= control.cell(row ,2).Text min= control.cell(row ,3).Text max= control.cell(row ,4).Text ave= control.cell(row ,5).Text f1.write(str(t) + " , " + str(max) + " , " + " , " + str(min) + " , "+str(ave) + "\n") f1.close()
0
This discussion has been closed.