Log In. Thank you for helping keep Eng-Tips Forums free from inappropriate posts. The Eng-Tips staff will check this out and take appropriate action. Click Here to join Eng-Tips and talk with other members!
Already a Member? Join your peers on the Internet's largest technical engineering professional community. It's easy to join and it's free. Register now while it's still free! Already a member? Close this window and log in. Are you an Engineering professional?
Join Eng-Tips Forums! Join Us! By joining you are opting in to receive e-mail. Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Ansys Mechanical Scripting
Students Click Here. Related Projects. I've never done something like this before and found nothing in the "workbench scripting guide".
The main problem I think is to try to get the values from the table and store them in variables in the script. And then put these variables in a function that create an Excel? Any sort of help from users who have some experience with this would be greatly appreciated as I struggle on it since a few days.
Many thx. In Ansys App store you can find an app called "Reaction forces". If you want your own modified version, you should first go through ACT tutorial course in Customer Portal to learn the basics. This is likely doable in APDL command snippet. Please see a previous thread for some pointers on force extraction.
To write text files to be read by Excel, here's a bit of sample code. Ansys Workbench is not script friendly to directly get the script working from Workbench project window. You have to use ACT Ansys customization toolkit to have this working. Simple way is to use APDL to get the reactions in file using command snippet. Hi, First of all thank you all for your help! As you told me I went through ACT these last days. I managed to export data from mechanical to excel by putting them as parameter by checking the box in mechanical.
Problem is that we can not set everything as parameter and even if we can, it won't be the best way to do. So my actual problem is how to go through the mechanical tree to get the value I want using ACT? If I get it well it should be something like this : GetTemplate.One thing we established is that customizing ANSYS Mechanical is not for the faint of heart, but at the same time, it is also not an impossible task. There are two primary difficulties associated with Mechanical customization.
They are:. What that means for us is that most of the functionality of ANSYS Mechanical is exposed to us through an interface that can be scripted. So, even though Mechanical may not have been explicitly designed to be scripted nor are the internals documented, yet we find that it is possible to script, and since the ANSYS developers have followed a consistent pattern, its internal structure is comprehensible by an outside agent.
That is the problem from 50, ft. Here are some more details about the problem. I want to add a command object to a particular body in the tree, and eventually I want to do it programmatically. Below is a screen shot of the context menu hierarchy one navigates through to insert a command object on a body in the tree.
Note that the string tables are located underneath a language directory structure. When we perform the search we find the following:. Sounds plausible. The file dscontextmenu. Here are the results of that search:. Note the structure of this file. There are various entries that represent individual menu items within a given context menu. For each entry there are a series of action callbacks that have an associated methodName attribute.
Stay tuned… there is much, much more to come. You must log in to post a comment.Learn more about SimuTrain or get started today by purchasing your subscription. However, with the wide spectrum of users, companies, and industries utilizing these products are used, it is impossible to provide a tool that does everything which all users might want it to.
Inevitably, individual users have their own preferred methods of working. Companies often have their own standardized procedures too. The APDL code these macros are written in is straightforward and well documented. ANSYS But right now, macros which might run in the Mechanical application are not documented at all. The good news is that while there is no formal documentation for creating macros to run within the Mechanical interface, there is a methodology that allows a motivated user to write macro code.
This article is not intended to be even an introductory training to writing macros for Mechanical, but to merely show some of the basic concepts, illustrate what is possible, and hopefully plant ideas about how macros could make your analysis life even easier. The interested reader is encouraged to contact SimuTech for further information on personalized instruction or contract work in this area. When the user clicks Solve, the Mechanical application creates a text based APDL input file which is then submitted in batch mode to the solver.
Many of these functions are defined the. Beyond this we need to attach a debugger to the Mechanical GUI process and look inside the code while it is running. While this will work, a better option is the proper debugger in Microsoft Visual Studio. In addition to having a debugger installed, the following registry setting must be in place:.
Once a debugger is installed, the Just-In-Time Debug registry key set properly, and a good text editor with directory search capabilities is at hand, we are ready to do something useful…. To illustrate the approach to writing a macro for Mechanical we will use a real world situation that I encountered several months ago.
A consulting project required setting up several hundred Remote Points at the center of annular faces representing washers. The first step is to determine what happens when we click the button to insert a RP. There will be multiple hits which correspond to different files defining multiple GUI locations where this functionality can be accessed. Now we need to be able to loop over the faces in a Named Selection and call this function for each one individually…. From here we need to fire up the debugger and get into the GUI code.
To do this we simply create a dummy Jscript macro file with one line of code, debugger. Assuming things are working properly, we will then be able to get into the code and go looking around. So we have now determined two functions which will be used in a loop to first clear out the selection, then select a single face from the original Named Selection in turn.
With a single face selected we can call the doInsertRemotePoint function, then more on to the next face. Determine how many faces in Named Selection 2. Find partId and topoId information for each face and store this information in an array 3. Because this article is running a bit long already we will wrap it up by noting that while every last nitty-gritty detail of our proposed macro has not yet been figured out, the approach described forms the foundation for writing macros.
Through more investigation using the debugger and some trial and error, we can come up with the final version of this macro which is listed at the end of this article.Log In.
Thank you for helping keep Eng-Tips Forums free from inappropriate posts. The Eng-Tips staff will check this out and take appropriate action. Click Here to join Eng-Tips and talk with other members! Already a Member? Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free. Register now while it's still free! Already a member? Close this window and log in. Are you an Engineering professional? Join Eng-Tips Forums! Join Us! By joining you are opting in to receive e-mail. Promoting, selling, recruiting, coursework and thesis posting is forbidden. Students Click Here. Related Projects. So far I have managed to set the python script up to create a input journal within ANSYS which creates and changes certain loads and geometries associated with that load case.
Part of that study looks at varying the preload in a bolt, obtaining an average stress from a path, then applying a force and obtaining the average stress again.
The difference between average stresses will be used as part of a study. I know I can create a CSV file to extract the results that I require, however what I am stuck on is how to use python or ANSYS commands to vary the initial preload in the study and then apply a load after this. Unfortunately I cannot define bolt preload using the parameters or specify a load to be applied after this.
Can anyone point me in the direction of the coding or method to use to alter the preload on the bolt and then apply a load on the load step after this. AddBoltPretension bolt. Children bolt. SetDefineBy 1,Ansys. Load bolt. SetDefineBy 2,Ansys. Lock bolt. AddForce myf. Hi Jason, Thanks for your reply.Perhaps these qualities of each interface come to mind for you as they do for me.
However, one glaring difference between the two products that has remained virtually unchanged since the beginning is in the area of scripting. Mechanical APDL is scriptable at its core.
It does what it does and that is that. Fortunately, that is only partially true. The reality is there is a whole underworld that exists in ANSYS Mechanical that is scriptable, it is just very cleverly and discretely hidden. You can imagine the mutiny that would occur, if every time a suit got the bright idea to change a product name, all the developers were required to rewrite their code to reflect the new name. So, what does DS look like on the inside? Well, the best I can tell it is architected this way:.
The outer shell aka the impenetrable black box is the GUI. Obviously, this is how the user typically interacts with the program. However, the GUI itself is not a statically compiled piece of executable code.
This is important for a couple of reasons:.ANSYS Customization Lesson-- Using IronPython Console
So what that means is that the text associated with all of the menus and buttons in the GUI; whether a GUI entity is a toolbar, or a toolbar button or a menu item; all of that is described textually inside these XML files.
You must log in to post a comment. Perhaps these qualities of each interface come to mind for you as they do for me Mechanical APDL is: Old looking and visually clunky. Quirky, but powerful.
Scriptable, Scriptable and More Scriptable. Great meshing and geometry support. Not scriptable. Well, the best I can tell it is architected this way: The outer shell aka the impenetrable black box is the GUI.
XML has structure. Brains really like structure. Stay tuned for the next installment to see this in action. Like this: Like LoadingAny or all tutorials available to students can be found in this discussion.
Depending on that answer, you can start with the ACT customization suite for that application. Regards, Sandeep Guidelines on the Student Community. Can you elaborate on what do you mean by repeating tasks. What exactly you want to automate - Geometry or some thing in Mechanical itself.
Hi Sandeep, Need to use scripting for automating repeating tasks. Mechanical is the end application. PratapBakke posted this 15 November - Last edited 15 November Hi Naveen, Can you elaborate on what do you mean by repeating tasks. Search in Post Topic. Popular Tags fluent ansys udf workbench cfd asc mesh fluid-dynamics error mechanical apdl cfx meshing structural-mechanics maxwell hfss static-structural general transient student This Weeks High Earners peteroznewman rwoolhou abenhadj 94 kkanade 64 tsiriaks 60 pblarsen 49 Aniket 35 Amin 29 Kremella 27 pnisc Recent Activity ShahryarMooraj is a new member in the forum.
Sooria is a new member in the forum. OFannan has been awarded the First Anniversary badge.Join Date: Jun It limits what you can do to only a few batch commands like generating points, planes, sketches, etc.
How does one select objects? How does one create a Named Selection, and how does one choose what goes in the named selection? I noticed that the help documentation instructs users to use the "agc. Yes, agc. Frozen, agc. TypeEdge3d, etc.
Access to the DesignModeler application functions is accessible via the prefix 'agb.
How do I write scripts to automate the ANSYS user interface?
LinePt. Last edited by ANT; July 23, at May 28,some more "revrse engineering" There are sooo many other interesting things not documented yet! But it's good enough source for those who has programmer experience. Some examples: Code:. Last edited by BaoBab; June 6, at June 6, Yavuz Hes. Both contributions help a lot. Thank you very much. June 6,Sample script.
Here is some practical example on DModeler usage: Task is: 1 load external CAD body 2 draw the surface under it using its bounds Code:. July 28,Design Modeler listing operations of a selected object. Join Date: Jul Thanks guys for posting these, its valuable for scripting enthuse persons.
I have 1 questions in the field of Design Modeler not sure how to get into it.