TAGGED: act, automatisation, mechanical, python, scripting
-
-
May 20, 2022 at 9:25 am
fabian.maier
SubscriberHello i wrote a Python script which basically imports a views.xml file and loads different model views from this file. This script already works fine but i would like to run it automatically each time a Mechanical Session is launched.
I don't want to use the "Connect/Run Python Code Objects When Mechanical is Launched", because the solution is being deleted when adding a Python Script to the Model Tree.
ACT would be an option, but i did not find a proper function to automatically call the function.
Is there any way to automatically run a python script when a mechanical is started?
Thanks in advance!
-
May 24, 2022 at 10:55 am
Aniket
Forum ModeratorWould you be able to create an extension and make it default, and then run this code using onload callback of this extension?
-Aniket
How to access Ansys help links
Guidelines for Posting on Ansys Learning Forum
-
May 31, 2022 at 2:23 pm
fabian.maier
SubscriberHello Aniket, thank you for your reply.
I tried to implement this in my extension, unfortunately, this doesn't work for some reason. I tried the extension with OnInit, OnReady and OnLoad, but nothing worked for me.
My xml file looks like this:
AutoImportViews
And the function AutoImportViews looks like this: ´╗┐
def AutoImportViews():
import os
result_loc = Model.Analyses[0].AnalysisSettings.SolverFilesDirectory
#dosomethinghere
´╗┐ #dosomethingmore
Is this setup correct for my application?
If i use the callbackwhat function input do i use in def AutoImportViews(input):? According to the ACT Guide it should be:
Called when a project is loaded.
[function(currentFolder)]
but i don't know how to set the correct input for OnLoad.
-
Viewing 2 reply threads
- The topic ‘Automatically run a Python script when starting Mechanical’ is closed to new replies.
Innovation Space
Trending discussions
- LPBF Simulation of dissimilar materials in ANSYS mechanical (Thermal Transient)
- Convergence error in modal analysis
- APDL, memory, solid
- Meaning of the error
- How to model a bimodular material in Mechanical
- Simulate a fan on the end of shaft
- Nonlinear load cases combinations
- Real Life Example of a non-symmetric eigenvalue problem
- How can the results of Pressures and Motions for all elements be obtained?
- Contact stiffness too big
Top Contributors
-
4167
-
1487
-
1363
-
1194
-
1021
Top Rated Tags
© 2025 Copyright ANSYS, Inc. All rights reserved.
Ansys does not support the usage of unauthorized Ansys software. Please visit www.ansys.com to obtain an official distribution.