Refreshing a Curve in Design Modeler Script
Hi all,
I created geometry in design modeler that includes a 3d curve. Now the points that generate the 3d curve are changed and I want to refresh the curve. I can easily refresh it inside the design modeler. But I want to refresh it using a script that can be run from ANSYS WB. “Refresh project” doesn’t refresh the curve. Can anyone guide me about the script? |
Quote:
Hey did you find a solution? |
Quote:
Yes. Just copy the following code into a .js file and then run the script. Here is the code: Code:
var NodeName = "Curve1"; //Name of 3d curve feature hope it helps |
Quote:
Hi and thank you for your reply! I've only used ansys through the GUI, so I'm sorry if my questions annoy you, I'm very new to ansys scripting. So, I'm trying to couple ansys fluent with a third software used for optimization. This software has a python node (the python node directly links with a workbench node, in a block system) which changes the points in a txt file that is then used by design modeler to create the 3d curve. Unfortunately, in the process, I've noticed that when building the geometry only some other ansys parameters are changed, as they should, but the curve rimains the same. So i was wondering: is there a way to run this .js script iteratively, every time my third software asks to run a simluation, so that the js script runs before the meshing etc and refreshes the curve? Thank you in advanced, I'm sorry to bother but I'm a bit stuck at the moment Have a nice day! |
Dear Fra Bla
The code I sent works only in the design modeler. So when you open the design modeler and run the .js file the curve must be updated. For the .js file to run automatically, you would need to write another script in WorkBench (of course in Python). This means you need to write a script to read and run the .js file, then update the mesh, then update the solver, etc. For doing this process iteratively I guess you should use your third software that you mentioned, in my case it was MATLAB. I don't know yours. If you think I can help you further, feel free to ask more questions. |
Dear Safasml,
I'm using modeFrontier for the optimization process. Do you think i can add some lines (that read and run your .js script) in the python node I already have working, the one which also changes the txt file? This way it could then update the workbench "normally". Or do I need to write a macro which tells to run separetely every step of the simumlation and add some lines of code to run your js script before e.g. the meshing? Thank you |
Yes, I guess you can add some lines to your own code. There is no need to write a separate one.
|
One last thing... do you know a link to some usefull guide for ansys scripting?
Thank you for everything! |
There are many YouTube videos about ansys scripting. Google it and you'll find what you're looking for.
WorkBench also allows you to record scripts. So there is no need to write anything. You can start recording and then do anything you want in the WB GUI. The script is then saved in .wbjn format after you stop recording. |
Hi!
In the end I managed to get it working, I had to use a macro written in python language which literally passes your .js script to the geometry: Code:
# encoding: utf-8 Thank you for your help! |
Changing the txt file
Quote:
Many thanks! |
I figured it out. Here's the part of my Workbench journal file from where it opens DesignModeler to when it closes it.
geometry1.Edit() #--- The following is performed in DesignModeler ---# # Locate the airfoil curve and set it equal to a variable named Crv1 geometry1.SendCommand(Command = """var Crv1 = ag.fm.Feature(3); // The curve is the 4th item in the feature tree // Change the airfoil coordinate file location Crv1.CoordinateFile = "file path";""") #--- After this, DesignModeler closes and we return to Workbench ---# geometry1.Exit() |
Well done!
In my case I was using another python block to change the coordinates of the txt file, so the workbench was always reading the same txt file, but with different values in it. |
All times are GMT -4. The time now is 18:06. |