Script run ok in standalone mechanical but problem with optiSLang

SK
SK Member Posts: 21
10 Comments First Anniversary Name Dropper
**

Hello,
I'm using below script to record natural freq from modal analysis and update user defined freq in a harmonic analysis. While it works fine on a standalone mechanical window but when I trying to solve same model through optiSLang script is not running. Note that scipr is inserted as a Python code, targate call back set to after pots. Please help me in this.

Code

def after_po
st(this, solution):# Do not edit this line
"""
Called after post processing.
Keyword Arguments :
this -- the datamodel object instance of the python code object you are currently editing in the tree
solution -- Solution
"""

# To access properties created using the Property Provider, please use the following command.
# this.GetCustomPropertyByPath("your_property_group_name/your_property_name")

# To access scoping properties use the following to access geometry scoping and named selection respectively:
# this.GetCustomPropertyByPath("your_property_group_name/your_property_name/Geometry Selection")
# this.GetCustomPropertyByPath("your_property_group_name/your_property_name/Named Selection")

solution=ExtAPI.DataModel.AnalysisList[0].Solution  #Modal analysis is first system
solution.Activate()
data=[]
del data[:]

Pane=ExtAPI.UserInterface.GetPane(MechanicalPanelEnum.TabularData)
Con = Pane.ControlUnknown
Rows=Con.RowsCount
data=[]
for R in range(2,Rows+1):
    Natf=Con.cell(R,3).Text
    data.append(Quantity(Natf+' [Hz]'))      # Store Natf
    fac=0.05*float(Natf)   #5% of natural frequency
    Fr1=float(Natf)+fac    # Fr1=Natf+5%
    Fr2=float(Natf)-fac    # Fr2=Natf-5%
    data.append(Quantity(str(Fr1)+' [Hz]'))  #Store the Fr1
    data.append(Quantity(str(Fr2)+' [Hz]'))  #Store the Fr1

harmonic_analysis = ExtAPI.DataModel.Project.Model.Analyses[1]  
harmo_settings = harmonic_analysis.AnalysisSettings
harmo_settings.UserDefinedFrequencies = True # activate User Defined Frequencies
harmo_settings.UserDefinedFrequencySteps = data

pass

Answers