Script run ok in standalone mechanical but problem with optiSLang

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
-
Did you activate Connect/Run Python Code Objects when Mechanical is Launched ? See https://discuss.ansys.com/discussion/2206/use-python-code-object-python-result-object-with-a-doe
0 -
Yes, @Landon Mitchell Kanner
Connect Python Code Objects when Mechanical is Launched is set to yes.0 -
I think the problem is .GetPane command (access the table pane), I read that this is this is not available when you have mechanical running in batch mode like design points. Can anyone help with an alternative method to .GetPane.
0