TAGGED: python
-
-
December 12, 2023 at 3:40 am
Smit Kapadia
Subscriber -
December 12, 2023 at 9:34 am
ErKo
Ansys EmployeeHi
There is not much description given.
We assume your refer to pyAnsys and pyMechanical?
See here for tutorials:
https://mechanical.docs.pyansys.com/version/0.8/getting_started/index.html
https://embedding.examples.mechanical.docs.pyansys.com/examples/basic/valve.html#sphx-glr-examples-basic-valve-py
Hope this helps
All the best
Erik
Â
-
December 13, 2023 at 1:32 am
Smit Kapadia
SubscriberHello, I was trying to launch Mechanical 2022 R1 with PyMechanical, which is not supported, so I installed 2023 R1, and the previous error is resolved.
However, I am having an issue with geometry import. I checked the geometry file path, it is correct and works when I run my code in Mechanical Scripting module. When I print the state of geometry import group, I get "NotSolved". Would anyone know why this happens?
Following is the error I get, with an embedded instance of Mechanical in Python:-

-
-
December 13, 2023 at 7:43 am
ErKo
Ansys EmployeeHi
Please install 2023 R2 and try this code (which works of course if all is set up ok):
import osimport smtplibimport ansys.mechanical.core as mechwork_dir = r'D:\PyAnsys\PyMechanical\demo'path_to_232 = r'C:\Program Files\ANSYS Inc\v232'app = mech.App(version=232) # starts a non-graphical Mechanical session within the python.exeglobals().update(mech.global_variables(app)) # update global variables to get access to the same Model, DataModel, etc variables as in the Mechanical scripting consoleâ€# Add static analysisanalysis = Model.AddStaticStructuralAnalysis()# Import geometrygeometry_file = os.path.join(work_dir,'Valve.scdoc')geometry_import = Model.GeometryImportGroup.AddGeometryImport()geometry_import_format = Ansys.Mechanical.DataModel.Enums.GeometryImportPreference.Format.Automaticgeometry_import_preferences = Ansys.ACT.Mechanical.Utilities.GeometryImportPreferences()geometry_import_preferences.ProcessNamedSelections = Truegeometry_import.Import(geometry_file, geometry_import_format, geometry_import_preferences)If you have any issues post your questions here:Âhttps://discuss.ansys.com/ÂIf any bugs/issues are found then publish here:Âhttps://github.com/ansys/pymechanical/issuesÂAll the bestErikÂÂ
-
- The topic ‘Having problem with launching embedded Mechanical instance in Python’ is closed to new replies.
-
6600
-
1906
-
1464
-
1311
-
1022
© 2026 Copyright ANSYS, Inc. All rights reserved.