-
-
September 22, 2023 at 2:48 pm
jean.collomb
SubscriberHi,
I am trying to create a user butter in order to accelerate my post-processing in Ansys Mechanical.
My dream when I click on the button is :
1- Create one folder with : total displacement ; 3 directional displacements ; VM stressÂ
2- Create one folder for a specific name selection with : total displacement ; 3 directional displacements ; VM stressÂ
3- Export these results (min/max values) in a csv file.
I found this command for the total displacement : ExtAPI.DataModel.Project.Model.Analyses[0].Solution.AddTotalDeformation()
But I don't know how to fin other commands for directionnal displacements, VM stress, for creating folders, exports results ...
Thanks you for your help :)
Jean
-
September 22, 2023 at 3:08 pm
Erik Kostson
Ansys EmployeeÂ
Â
Â
Â
Â
Â
Â
Hi
You can use the record in the mechanical scripting console, and add the directional deformation , etc., and you will see the commands (e.g., AddDirectionalDeformation(), AddEquivalentStress(), etc.)
On how to het the max/min from these results, one can get that by:
equivalent_stress = ExtAPI.DataModel.Project.Model.Analyses[0].Solution.AddEquivalentStress()
MaxVMSt=equivalent_stress.Maximum
Then export MaxVMSt to a csv file. Search the internet how to export there are many posts on that, e.g., :Â
https://www.programiz.com/python-programming/writing-csv-files
Finally group is a bit hard, but not really needed in order to create the results, extract max/min and export these values.
If needed folders/groups look at the below link for an example that adds these results and puts them into a folder.
https://discuss.ansys.com/discussion/2540/how-can-add-certain-results-and-group-them#latest
All the best
Erik
Â
Â
Â
Â
Â
Â
Â
-
October 5, 2023 at 7:59 am
jean.collomb
SubscriberHi Erik,
Thanks a lot for your answer!
I try with a simple code, and it works!
I have two more questions:
1- Is there any documentation to easily get these informations ?
2- I try to create a displacement result for a named selection, but the record is incomplet I guess. I get the command bellow where the scoping method is "named selection", but I don't know how to affect a named selection.
total_deformation_45 = solution.AddTotalDeformation()
total_deformation_45.ScopingMethod = GeometryDefineByType.ComponentThanks a lot,
Jean
nb : I did not try the export for now.
Â
Code example:
#----------------------------------------------------------------
solution = ExtAPI.DataModel.Project.Model.Analyses[0].Solution
#----------------------------------------------------------------Â
#----------------------------------------------------------------
resgr=[]# Déplacement selon x, y, z, total
directional_deformation_global_x = solution.AddDirectionalDeformation()
directional_deformation_global_x.NormalOrientation = NormalOrientationType.XAxis
directional_deformation_global_y = solution.AddDirectionalDeformation()
directional_deformation_global_y.NormalOrientation = NormalOrientationType.XAxis
directional_deformation_global_z = solution.AddDirectionalDeformation()
directional_deformation_global_z.NormalOrientation = NormalOrientationType.XAxis
total_deformation_global = solution.AddTotalDeformation()# Contraintes equivalentes Von Mises
equivalent_stress_global = solution.AddEquivalentStress()resgr.append(directional_deformation_global_x)
resgr.append(directional_deformation_global_y)
resgr.append(directional_deformation_global_z)
resgr.append(total_deformation_global)
resgr.append(equivalent_stress_global)dossier_global = ExtAPI.DataModel.Tree.Group(resgr)
dossier_global.Name = "Global"
#---------------------------------------------------------------- -
October 5, 2023 at 9:58 am
Erik Kostson
Ansys EmployeeHi
- See this link: https://ansyshelp.ansys.com/account/secured?returnurl=/Views/Secured/prod_page.html?pn=Customization%20Suite&prodver=22.2&lang=en
- See the link here on how to scope results to named selection (if this is not what you want search in the dev. forum): https://discuss.ansys.com/discussion/909/insert-total-deformation-result-in-modal-analysis-scoped-to-a-named-selection-and-define-maximum-and
All the best
Erik
-
October 5, 2023 at 11:52 am
jean.collomb
SubscriberHi Erik,
Thanks for your answer.
Regards,
Jean
-
- The topic ‘User button – Python commands’ is closed to new replies.
-
2984
-
970
-
857
-
755
-
599
© 2025 Copyright ANSYS, Inc. All rights reserved.