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
Ansys EmployeeWould 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.
-
- You must be logged in to reply to this topic.

Boost Ansys Fluent Simulations with AWS
Computational Fluid Dynamics (CFD) helps engineers design products in which the flow of fluid components is a significant challenge. These different use cases often require large complex models to solve on a traditional workstation. Click here to join this event to learn how to leverage Ansys Fluids on the cloud, thanks to Ansys Gateway powered by AWS.

Earth Rescue – An Ansys Online Series
The climate crisis is here. But so is the human ingenuity to fight it. Earth Rescue reveals what visionary companies are doing today to engineer radical new ideas in the fight against climate change. Click here to watch the first episode.

Ansys Blog
Subscribe to the Ansys Blog to get great new content about the power of simulation delivered right to your email on a weekly basis. With content from Ansys experts, partners and customers you will learn about product development advances, thought leadership and trends and tips to better use Ansys tools. Sign up here.
- Saving & sharing of Working project files in .wbpz format
- Solver Pivot Warning in Beam Element Model
- Understanding Force Convergence Solution Output
- An Unknown error occurred during solution. Check the Solver Output…..
- What is the difference between bonded contact region and fixed joint
- whether have the difference between using contact and target bodies
- User manual
- The solver engine was unable to converge on a solution for the nonlinear problem as constrained.
- Colors and Mesh Display
- material damping and modal analysis
-
3930
-
2649
-
1861
-
1272
-
610
© 2023 Copyright ANSYS, Inc. All rights reserved.