TAGGED: python-scripting
-
-
March 1, 2024 at 6:35 pm
Matthew Little
SubscriberWhen writing a script in Mechanical, the entire Ansys Python class is already in there, and to access the Model, you just type 'Model'. I'm working on a project where I import another script into Mechanical, but because it's imported, it doesn't have the Ansys namespace.
I can't seem to find what I need to import from Ansys to access Model. Seems like it should be Ansys.ACT.Automation.Mechanical.Model, but that doesn't give any options to access anything within the model (e.g., Model.Analyses).
Any clue as to where all of this info is hidden in the classs?
-
March 4, 2024 at 1:22 pm
Matthew Little
SubscriberAfter a few more searches, I found a solution. In the imported module, you must 'initialize' the Ansys objects you want to use (e.g., ExtAPI, Ansys). Create a function that takes whatever objects you want and set them to global variables in the imported module.
In the main Ansys script, after you load your module, you call the initialization function to pass whatever Ansys namespace functions (ExtAPI, Ansys, etc.) to you module.
This sort of seems like a workaround, and i feel like there should be a direct way to import the needed objects.
-
March 4, 2024 at 2:49 pm
mjmiddle
Ansys EmployeeSending the ExtAPI and Ansys objects to your model in an initialization function is the best way.
-
- The topic ‘Scripting in Mechanical – Accessing ‘Model’’ is closed to new replies.
- Workbench license error
- access to path files denied error
- Unable to connect to the license
- Tutorial or Help for 2 way FSI
- lmgrd is not running: License server machine is down or not responding.
- Moment Reaction probe with Large deformation
- Running multiple LS-DYNA simulations with batch files
- Problem with ANSYS installation
- Ansys with Vmware and CPU configuration : I’m lost, good practice?
- Ansys 2025 R1 Student Licensing Issue
-
2407
-
930
-
599
-
591
-
569
© 2025 Copyright ANSYS, Inc. All rights reserved.