Script Model - Mechanical
Hello everyone,
I have to script a complete ANSYS analysis and allready managed to write a script with MATLAB which generates the engineering data and the geometry of a tooth from a gear-wheel (by importing points and create Skin's out of these). Now I have to script all the meshing and external loads, fixed supports, ... by using the ANSYS Mechanical Feature (Model). My question: Does anybody know where I can find information how to script the Mechanical feature of ANSYS? I couldn't find any helpful information in the "ANSYS Scripting Guide" or in the "Mechanical Application" directory (ANSYS HELP). Or does anybody has done some scripting on ANSYS Mechanical in the past? Edit: Maybe I can solve the problem by using Icem CFD and do it manually and record all of my steps - does anybody tried this before? Best Regards Max |
Hi Max,
By quick search thru JS files in Ansys folder, I found this! Code:
//Accesing the boundary conditions properties Similar to this you can create, fixed support You need to create Named Selection for the faces where you are applying force and support so that you can call them when you are running your script. Hope it helps Cheers KAPI |
Quote:
I managed to script MeshSizing and some other things but at the moment I have problems to find the "DS.Script.doInsert.." for FixedSupport in the .xml and .js files in Ansys directory. This here doesn't work .. it says that "DS.Script.doInsertEnvironmentFixedSupport();" doesn't exist: Code:
var SelStatStruc=DS.Tree.FirstActiveBranch.Environment; Best Regards,Max EDIT: this one doesn't work ether: Code:
DS.Script.localString("ID_EnvironmentInsertDisplacementFixedSupport"); |
Hi Max,
Good Day!! Try this! Code:
DS.Script.doInsertEnvironmentFixedDisplacement(1) Cheers KAPI |
1 Attachment(s)
Quote:
I have another problem in Mechanical when it comes to mesh my geometry: I don't have problems to change the value of "Physics Preference" for example but I don't know how to access the parameters for "Sizing" (it is closed and has to be opened with the "+" infront) When I want to change the "Sizing" -> "Min Size" an error says, that "Min Size" doesn't exist. I hope you understand what I mean - I have attached an example. Best regards, Max |
Hi Max,
You need to find particular functions just like you found physics preference, just search more! Anyways this will help! Code:
meshGroup.MinSizeSF = 0.0001; Cheers KAPI |
Quote:
I have another question: I couldn't find anything for selecting a force in my mechanical tree outline and activate this one. I tried several codes like this ones: Code:
var SelForce=DS.Tree.FirstActiveBranch.Environment.Load(1); Thank you for all your help! Best regards, Max |
Hi Max,
Quote:
What I mean is you can give values of force when you first created the force by the below code (for ex: force at top of the strcuture) Code:
DS.Script.doInsertEnvironmentForce(1) Cheers KAPI |
Quote:
So it would be nice if you could check this! Best regards Max |
.. I will try to delete this force and create a new force .. maybe this works
.. have you used "commands" in the tree outline of Mechanical Ansys? Can I change the material by overwrite the material properties in APDL code? |
Hi Max,
Yea you can try to delete force and add new one. You can try to make it parametric as well so that you can run the same simulation by only changing force. I have not done much on Ansys mechanical Tree outline so I have limited knowledge. Cheers KAPI |
I figured out how to access features (pressure, fiexed support, force, ..) in the tree outline:
Code:
DS.Tree.FirstActiveBranch.Environment.Loads.Item(i); |
Good Job Max,
I have been busy lately, will get back to CFDOnline by tuesday most likely! |
Quote:
Hi, I'm working with a similar project and have the same problem as you have. I'd like to select an already existing load in the tree and make changes. Lets say that we have a pressure load and we like to supress it. Would the code be like: Code:
DS.Tree.FirstActiveBranch.Environment.Loads.Pressure(i); I'm not sure if i should change item to pressure or ad a number instead of i? |
Quote:
"item" is for all of the different external inputs like pressure, force, .. the same. You get access to the different loads by replace the "i" with the position in your tree of the item which you want to select. So for example you have in your "loads" a fixed support at first position and a pressure on second position. to select the pressure and set it to "unsuppressed" the code should be the following: Code:
var SelPressure = DS.Tree.FirstActiveBranch.Environment.Loads.Item(2); Best Regards, Max |
Quote:
Thank you so much, it work, but i also have a question regarding how to change the analysis settings, for example NumberOfSetps? Code:
var SelAnslysis = DS.Tree.FirstActiveBranch.Environment.Loads.Item(2); Thanks for your assistance |
Quote:
I also have another question: in Mechanical you have the option to export a file with the result of the displacement. Does anybody know the code to do this export? Best regards Max |
Hi Max,
I think you have to use "Send Command" in .wbjn file to export your result with Displacement. I have never used export command in mechanical but I used once for CFX result file. Cheers KAPI |
Quote:
can you share the code for export CFX result file? Maybe it will be quite similar to export the Mechanical result file?! Best regards, Max EDIT: I figured out how to export a specific solution (in my case: Displacement on a node) into a txt-file or in a Excel-file. here is the code (to write in txt-file use:"DS.Script.doExportToTextFile(FilePath="XXX")" ): Code:
var SelDis=DS.Tree.FirstActiveBranch.AnswerSet.Results.Item(1); Best regards, Max |
Quote:
Hi Kapi, Do you know how to handle the command snippet with the journal script?` I can access all loads and results with the codes: Code:
var SelExtMoment = DS.Tree.FirstActiveBranch.Environment.Loads.Item(2); Code:
var SelCommands = DS.Tree.FirstActiveBranch.AnswerSet.Item(1); If the snippet is in place 3 and I choose Item(3) it skips the snippet and suppress the next item. Do you know how to handle this? Thanks // Joakim |
All times are GMT -4. The time now is 19:34. |