TAGGED: pyansys, python-scripting, scripting, units
-
-
January 10, 2025 at 6:26 pm
cardiac.scripter
SubscriberHi,
I'm having a problem with my units. They are not staying consistent.
I import my model as an .inp. The mesh is constructed in mm.# Import the modelmimp=Model.GeometryImportGroup.AddModelImport()mimp.ModelImportSourceFilePath=input_filemimp.Import()
I set the units:analysis = Model.AddStaticStructuralAnalysis()analysis.AutomaticTimeStepping = AutomaticTimeStepping.Onanalysis.InverseOption = Trueanalysis.LargeDeflection = TrueExtAPI.Application.ActiveUnitSystem = MechanicalUnitSystem.StandardNMMdat
But the mesh is imported as 5e4mm even though it should be in region 5e1mm.
When I load the sampe input file in the GUI I don't get this problem.
When I load my pressure
in MPa -
January 13, 2025 at 7:46 am
Erik Kostson
Ansys EmployeeHi
For the geometrey units issue. We need to set the units of the imported cdb file. See here where I have added that in the end of my post.
https://discuss.ansys.com/discussion/4431/how-to-add-a-model-in-standalone-mechanical
As for the hbar pressure issue, that comes from using the StandardNMMdat – I would suggest to use NMM or NMMton
in ExtAPI.Application.ActiveUnitSystem = MechanicalUnitSystem.StandardNMMdat
and that will have MPa units.
To close of, I would suggest to post this type of questions (pymechanical and script type), in our dedicated script forum
here: https://discuss.ansys.com/
or if there is a bug/issue with pymech., then in github:
https://github.com/ansys/pymapdl/issues
All the best
Erik
PS: In the pressure load change unit to MPa from Pa see below marked:
Pressure.Magnitude.Output.DiscreteValues = [Quantity(“0 [Pa]“), Quantity(“-1.0666e-002 [MPa]”)] -
January 13, 2025 at 11:14 am
cardiac.scripter
SubscriberHi Erik,
That worked! Thanks for your help.
Yes I've seen this forum. However, I cant find the button for posting a new discussion topic aha.
Here is my home page:
And thsi is when I open structures:
Do I need to be approved before I can post? Or am I just being stupid and can't see the "Start New Discussion" button?
Thanks in advance. -
January 13, 2025 at 12:51 pm
Erik Kostson
Ansys EmployeeHi
What is your user name there and I can check why it has not been approved yet (like you say think it needs some approval)?
All the best
Erik
-
January 13, 2025 at 12:59 pm
Erik Kostson
Ansys EmployeeHello
Many thanks - you should be ok now (you should have recieved an email about it also).
All the best
Erik -
January 13, 2025 at 1:01 pm
cardiac.scripter
SubscriberSorted!
-
January 13, 2025 at 1:04 pm
Erik Kostson
Ansys Employeeperfect – anything else (script related) post there and we will try to help.
-
-
- The topic ‘Units are not consistent, when scripting in pyMechanical’ is closed to new replies.
- How to apply Compression-only Support?
- At least one body has been found to have only 1 element in at least 2 directions
- Error when opening saved Workbench project
- Geometric stiffness matrix for solid elements
- Script Error Code:800a000d
- Timestep range set for animation export
- Image to file in Mechanical is bugged and does not show text
- Elastic limit load, Elastic-plastic limit load
- Element has excessive thickness change, distortion, is turning inside out
- BackGround Color
-
1617
-
613
-
599
-
591
-
366
© 2025 Copyright ANSYS, Inc. All rights reserved.