CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > ANSYS Meshing & Geometry

[Workbench] SCRIPT for geometry / meshing

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree1Likes
  • 1 Post By Nigirim

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 1, 2014, 22:49
Thumbs up SCRIPT for geometry / meshing
  #1
Senior Member
 
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 13
Kapi is on a distinguished road
Hi guys,

I am starting this new thread to talk to people who are doing scripting for geometry and meshing like me.

Query:
When we run .wbjn file thru batch file and call .js files to do geomtry and mesh. After it finishes meshing we use...

mesh1.Exit()

and mesh closes.

Now my problem is when I run multiple .wbjn files one after the other from the same batch file. The second .wbjn file dosent execute unless I close the first WB.

Do you guys have any idea how to automatically close WB after meshing is done?
I think it cant be done from .wbjn file, there shud be some function to run in batch file itself to close first WB and start next .wbjn file.

Any help will be highly regarded
Thanks in advance

Cheers
KAPI
Kapi is offline   Reply With Quote

Old   April 2, 2014, 09:46
Default
  #2
New Member
 
Join Date: Sep 2012
Posts: 26
Rep Power: 13
Nigirim is on a distinguished road
Hi Kapi,

you can close WB by simply adding -X to the command you start ANSYS with.
-X closes WB as soon as the script is completely executed.
Then you can open WB again for your other journal files.

Greets
Nigirim
Kapi likes this.
Nigirim is offline   Reply With Quote

Old   April 2, 2014, 18:56
Default
  #3
Senior Member
 
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 13
Kapi is on a distinguished road
Thanks for reply Nigirim,

Quote:
Originally Posted by Nigirim View Post

you can close WB by simply adding -X to the command you start ANSYS with.
-X closes WB as soon as the script is completely executed.
Then you can open WB again for your other journal files.
so basically as we run the below command to open the WB and execute our code
"C:\Program Files\ANSYS Inc\v145\Framework\bin\Win64\RunWB2.exe" -I -R File_name.wbjn

what you are suggesting is to add -X in the above code and run?
like this?

"C:\Program Files\ANSYS Inc\v145\Framework\bin\Win64\RunWB2.exe" -I -R -X File_name.wbjn

Edit:

I just ran the above code using -X, what it is doing is opening the WB and closing straight after.
so basically it dosent run the .js code I have provided to make geometry and mesh and closes.

Could you provide the code which uses -X , I will try few things as well to get it working.

Cheers
Kapi

Last edited by Kapi; April 2, 2014 at 19:15. Reason: tried code with -X
Kapi is offline   Reply With Quote

Old   April 2, 2014, 19:38
Default
  #4
Senior Member
 
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 13
Kapi is on a distinguished road
Got it working!!

Just add some code in Fil_name.wbjn and saved the WB as "check.wbpj"
then ran the below code

"C:\Program Files\ANSYS Inc\v145\Framework\bin\Win64\RunWB2.exe" -I -R File_name.wbjn -X check.wbpj

Thanks heaps for your suggestion Nigirim


Cheers
KAPI
Kapi is offline   Reply With Quote

Old   April 2, 2014, 20:33
Default Script Selective Meshing
  #5
Senior Member
 
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 13
Kapi is on a distinguished road
New Query:

There are code available to run mesh thru java script, the problem is it meshes the whole thing in 1 go.
We can pick bodies manually one by one and mesh them or we can create worksheet inside for selective meshing.
I want my java script to pick bodies one by one from the tree(Model>Geomtry>Part>Body1) and mesh it, this way meshing is lot quicker when it comes to large model with lot of bodies and a coarse mesh.

The code I am using to mesh is below, it meshes everything in 1 go

ds.Script.doModelPreviewMesh();

I checked help and all in my model is having "Part" because if we go in Mesh help it says:
In a multibody part, if any child bodies have been meshed and refined, another child body is unmeshed, and you subsequently mesh the unmeshed body, the mesh state of all refined bodies in the part will be invalidated and re-meshed during mesh generation. Similarly, if one body is unmeshed and refinement is needed on another, generating the mesh will result in meshing and refinement of the entire part

Does that mean I cant do selective meshing in a part?
I tried doing this manually and it works without any problem.

So now I need code which can go into "Part" and select bodies one by one and mesh it.

Anyone with ideas?

Thanks in advance
Cheers
Kapi
Kapi is offline   Reply With Quote

Old   April 3, 2014, 08:44
Default
  #6
New Member
 
Join Date: Sep 2012
Posts: 26
Rep Power: 13
Nigirim is on a distinguished road
Hi Kapi,

how does your script work in general?
Are you creating a new Workbenchprojekt every time you start the script or are you loading and modifying a existing project?

In general I would say it is possible, everything you can do in the GUI is handeld by XML and JScript.
But I am not 100% certain it works this way.

There are JScript commands that select the bodies in the Tree, I have never tried to select and then mesh the bodies one by one.
I have loaded a existing Workbenchproject and modified it. To mesh I just used the Worksheet I once created for every single body.


Greets
Nigirim
Nigirim is offline   Reply With Quote

Old   April 3, 2014, 19:26
Default
  #7
Senior Member
 
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 13
Kapi is on a distinguished road
Hi Nigirim,

Thanks for replying back.

Quote:
Originally Posted by Nigirim View Post
how does your script work in general?
Are you creating a new Workbenchprojekt every time you start the script or are you loading and modifying a existing project?
Yes I am creating a new project everytime because I have different geometry everytime.

Quote:
Originally Posted by Nigirim View Post
In general I would say it is possible, everything you can do in the GUI is handeld by XML and JScript.
But I am not 100% certain it works this way.
It does work manually so I think it should work with codes as well.

Quote:
Originally Posted by Nigirim View Post
There are JScript commands that select the bodies in the Tree, I have never tried to select and then mesh the bodies one by one.
I have loaded a existing Workbenchproject and modified it. To mesh I just used the Worksheet I once created for every single body.
I have tried few commands to work it out but was not successful and the reason I cant use worksheet is because I dont have similar name, size or pattern of bodies in the tree. Thats why I have to select bodies from tree at that instance and mesh it.
Could you please share your JS command to select bodies in tree, may b that can help in my case.

Is it possible to create worksheet thru JS commands and make that worksheet select the bodies from geomtery 'part'?
I see a problem in selecting bodies from tree when there is Part with multiple bodies because what we actually need the code should go in the tree, select part, go inside part and select bodies from top to bottom and mesh them.

I hope I am able to explain my problem.

Thanks
Kapi
Kapi is offline   Reply With Quote

Old   April 4, 2014, 08:33
Default
  #8
New Member
 
Join Date: Sep 2012
Posts: 26
Rep Power: 13
Nigirim is on a distinguished road
Quote:
Originally Posted by Kapi View Post
Hi Nigirim,


Could you please share your JS command to select bodies in tree, may b that can help in my case.
Hi Kapi,

its been a while since i last used the command for the Meshing tool, so I am not 100% certain that it is the same as for DesignModeler (This one i used way too much)

Code:
ag.guiScript.SelectFeatureNodeByID(BODY_ID)
I can't have a look at my old scripts, because I changed my workplace so I can't tell you the exact commands.

I used this command in a loop to select threw the bodies to give them Bodythickness.

I never made a Worksheet by Script and never took a look if it is possible, so I can't tell you if it works or not.

Hope this helps
Greets
Nigirim
Nigirim is offline   Reply With Quote

Old   April 6, 2014, 19:40
Default
  #9
Senior Member
 
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 13
Kapi is on a distinguished road
Thanks Nigirim

the below code is for geometry not mesh sadly.
"ag" is used in geometry and "ds" is used in meshing to prefix the function
Code:
ag.guiScript.SelectFeatureNodeByID(BODY_ID)
I have tried to do loop the body and mesh it but the problem I am facing is, unless I select a part or a body manually that code dosent execute.

so basically if I manually select a "body" in the tree and run my JS file it work smoothly but it dosent do anything if I select "geometry" or "Model" in the tree.

Making worksheet is outta question cuz I will not be able to give any specifics of bodies to work on it. the only thing left is to force my JS script to select a body and then run the script.

Lets c if I am able to do that.

If anyone else has any input here then it wil be really helpful


Cheers
KAPI
Kapi is offline   Reply With Quote

Old   April 16, 2015, 02:32
Smile
  #10
Member
 
Join Date: Oct 2014
Posts: 44
Rep Power: 11
kar.coep is on a distinguished road
Hello Kapi,I am trying to achieve the same process as you are saying in this post. I have searched a lot, contacted Ansys guys but doesn't seem to get any documentation on DM and meshing programming as such. Can you give a intro on how to start with this programming or provide relative Jscript coding if it is easy? It would be really helpful.In DM what I am trying to achieve is:1. import external geometry from Creo2. Create inlet and outlet surfaces and have Fill3. Create named selections for inlet and outlet4. suppressing the body5. forming new part with new generated domainsAlso, is there a way to record Jscript coding in DM and Meshing?Thanks.
kar.coep is offline   Reply With Quote

Old   April 16, 2015, 03:11
Default
  #11
Senior Member
 
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 13
Kapi is on a distinguished road
Hi Kar,

Good Day!
There is no way to actually record the script but to hard code it.
Are you using Ansys 15 or 16?
I was told recently that in 16 there has been lot of documentation on scripting
To start with you need to go "Help" section and read about scripting("Ansys Customization"), its quiet useful and then Ansys Customer portal for examples which are very useful to understand the process!
Ansys Customization Toolkit (ACT) is the fully documented in Ansys 16
This way you will not only be able to script but will understand how to decode/ debug Ansys functions.
If you are stuck at some point then let me know, I can help you get functions for your JS.

Cheers
KAPI
Kapi is offline   Reply With Quote

Old   April 16, 2015, 04:58
Post
  #12
Member
 
Join Date: Oct 2014
Posts: 44
Rep Power: 11
kar.coep is on a distinguished road
Thanks for the quick reply!!!
I am using Ansys 15

What I want to do in DM is

1. Import external geometry
2. Create Fill with 2 surface
3. Create named selections for inlet and outlet
4. Suppress geometry and form new part of domains
kar.coep is offline   Reply With Quote

Old   April 16, 2015, 19:48
Default
  #13
Senior Member
 
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 13
Kapi is on a distinguished road
Hi Kar,

In Ansys 15: Help> Workbench>Scripting Guide, you should be able to find answers to your questions.
They have Usage Examples in that scripting guide as well. Have a go at it and check Customer Portal for Examples.

Hope it helps

Cheers
KAPI
Kapi is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[ICEM] Problem with ICEM Script Meshing asal ANSYS Meshing & Geometry 2 March 23, 2013 20:11
[ICEM] script for cylinder hexa meshing in ICEM Far ANSYS Meshing & Geometry 0 May 25, 2012 08:55
Singularity of grid?Volume meshing vs face meshing Ken Main CFD Forum 0 September 4, 2003 12:09
Volume Meshing & Face Meshing? singularity of grid ken FLUENT 0 September 4, 2003 12:08


All times are GMT -4. The time now is 10:31.