How can we export the Acoustic AWeightedSPL FR result data using mechanical scripting?

Erik Kostson
Erik Kostson Member, Moderator, Employee Posts: 312
50 Answers 100 Comments Second Anniversary 25 Likes
✭✭✭✭
edited March 5 in Structures

We want to first add an Acoustic A-Weighted SPL frequency response (FR) result, and then export/print the result data using mechanical scripting?

Best Answers

  • Erik Kostson
    Erik Kostson Member, Moderator, Employee Posts: 312
    50 Answers 100 Comments Second Anniversary 25 Likes
    ✭✭✭✭
    edited March 6 Answer ✓

    It can be done in the following way (as the ExportToTextFile method is missing for this result object):

    model=ExtAPI.DataModel.Project.Model # refer to Model
    analysis = model.Analyses[0]
    solution=analysis.Solution
    ns=ExtAPI.DataModel.GetObjectsByName('Open Domain')[0]
    res=solution.AddAcousticAWeightedSPLFrequencyResponse()
    res.Location=ns
    res.EvaluateAllResults()
    res.Activate()
    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 
    
  • Erik Kostson
    Erik Kostson Member, Moderator, Employee Posts: 312
    50 Answers 100 Comments Second Anniversary 25 Likes
    ✭✭✭✭
    edited March 5 Answer ✓

    If the result exists and the resulting data is there, then we need to activate the result object first before using the paneTabular function:

    rs=ExtAPI.DataModel.GetObjectsByName('Frequency Response')[0]
    
    rs.Activate()
    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
    
This discussion has been closed.