General Mechanical

General Mechanical

[how to include a script as function inside of a mainScript from Workbench]

    • ramiromena
      Subscriber
      Dear Ansys Learning Forum Team,nI managed to create two independent Python scripts (one for SpaceClaim to generate the geometry and another to setup a Steady state thermal case).nThanks to your post [1], I was able to join and execute both scripts from Workbench by following the provided instructions as a mainScript.nHowever, I would like to have more flexibility on my mainScript. My question is:nQ: Maybe there is a way to add the initial scripts as python functions or similar? ( so that I will pass an argument before execute them?)nI am asking because I will need to control the script in the following way:n(A) to control the simulation setup (as meshingn(B) to run multiple analyses with the same setup (defined on the thermal script) but with an APDL that takes an external file as an input, which will act as a predefined load.nFor case (B) as a work-around option, I was thinking to add the system of External Data each time and defining there the file, but I would prefer the function style (in order to minimize the numbers of systems in the mainScript).nThank you in advance.nRamiron[1] https://forum.ansys.com/discussion/19206/run-mechanical-macro-from-workbench?n
    • Aniket
      Ansys Employee
      For A: You can write a text file based on your arguments and then later read this file for sendcommand nFor B: Would't it be easier to automate APDL directly instead of opening workbench?n-AniketnHow to access Ansys help linksnGuidelines for Posting on Ansys Learning Forumn
    • ramiromena
      Subscriber
      nThank you for your reply.nAt the moment, I will explore your suggestion for option A, as I have previous experience working with python scripts.nRegarding option B, I am interested on using Workbench because I need to run a parametric analysis that first solve the problem in Mechanical and then, it uses the result as an input for Fluent. I solved already the problem manually, so now I am trying to write a script to automatize the process.nRegards,nRamiron
Viewing 2 reply threads
  • You must be logged in to reply to this topic.