CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   ANSYS Meshing & Geometry (https://www.cfd-online.com/Forums/ansys-meshing/)
-   -   [DesignModeler] find features of Gambit in DesignModeler (https://www.cfd-online.com/Forums/ansys-meshing/84466-find-features-gambit-designmodeler.html)

code_source January 31, 2011 03:41

find features of Gambit in DesignModeler
 
Hello
I am a new user of DesignModeler, I always worked with Gambit. I have a geometry that I did with Gambit (.jou) and I want to reproduce it in DesignModeler. I have some difficulties which block me :
1 / How to move, union and subtract volumes (features "move", "unite" and "subtract" in Gambit)?
2 / How to reproduce:
Code:

edges round "edge.1" "edge.2" radius1 0.002
 volume blend
 edge create project "edge.2" face "face.1" vector 0 0 1
 face create skin "edge.12" edge.21 "directions 0 0
 face split "face.10" connected keeptool face "face.29"
 smooth face

on DesignModeler?

Thank you a lot for your help

sac January 31, 2011 08:21

Quote:

Originally Posted by code_source (Post 292899)
Hello
I am a new user of DesignModeler, I always worked with Gambit. I have a geometry that I did with Gambit (.jou) and I want to reproduce it in DesignModeler.

All of your questions are covered in the DM Training. If you've not been on it then I suggest you do.

Quote:

I have some difficulties which block me :
1 / How to move, union and subtract volumes (features "move", "unite" and "subtract" in Gambit)?
Under the create menu:

  • Union, Subtract are boolean operations.
  • Move is a body operation.

Quote:

2 / How to reproduce:
Code:

edges round "edge.1" "edge.2" radius1 0.002
 volume blend
 edge create project "edge.2" face "face.1" vector 0 0 1
 face create skin "edge.12" edge.21 "directions 0 0
 face split "face.10" connected keeptool face "face.29"
 smooth face

on DesignModeler?

Thank you a lot for your help
Blend is under the create menu.
Projection is under the tools menu.
Face split is under the tools menu.

code_source January 31, 2011 08:42

thank you (sac) very much for your reply, it helped me a lot.
Do you have a DM Training that you advise me?

sac February 1, 2011 09:29

Quote:

Originally Posted by code_source (Post 292959)
thank you (sac) very much for your reply, it helped me a lot.
Do you have a DM Training that you advise me?

You can either do local or online courses (or find a local reseller doing the same):

http://www.ansys.com/Support/Training+Center

PSYMN February 1, 2011 20:23

There is even a course on the customer portal specifically for Gambit users moving over to DM. It redoes all the Gambit tutorials using the DM tool.

Simon

dibetao April 7, 2011 13:47

Can I do boolean operation by python scripting?

PSYMN April 8, 2011 09:12

DM is persistent, no script needed.
 
Do you mean a geometry operation?

Python is for the schematic, within each application you must use the scripting method of the application. If you are talking about doing a Boolean in DesignModeler, then you would do it the way DM does it... With persistence instead of a script.

In other words, you don't need a script... Just do it in DM and if you later make upstream adjustments, DM can still update and perform the Boolean, just like a script would.

Best regards,

Simon

dibetao April 8, 2011 10:22

Thanks for reply, Simon.

I really need to do a script with boolean operation in DM. My script is wrote in python, and it reads a file of many circles and one box (2D). My geometry is complex, and I need to cut the circles of the box. So, I have to use the substract operation. I can load the box and circles by a script, and I can cut them by mouse selection (menu, boolean operation set).

However, I still don't know how make all proccess automatically through a script. I need to do that because my analysis requires many samples. Each sample is made of many circles. So, that proccess could speeds up my work.

PSYMN April 8, 2011 10:43

Sorry, I don't know.

rohit_8481 July 24, 2011 07:22

Hey Dibetao... U can make the process automatic by using a Javascript... For the circle sketches u can simply make Design Modeler write out sketches of active planes. While for the operation u need simple bits of code like this:

var XYPlane = agb.GetXYPlane();
agb.SetActivePlane(XYPlane);
var ps1 = planeAirfoilRoot (new Object());
var plane1 = agb.PlaneFromPlane(XYPlane);
plane1.AddTransform(agc.XformZOffset, 0.50);
agb.Regen();
agb.SetActivePlane(plane1);
var ps2 = planeAirfoilTip (new Object());
var ext1 = agb.Skin(agc.Add,agc.No,0.0,0.0);
ext1.AddBaseObject(ps1.Sk1);
ext1.AddBaseObject(ps2.Sk2);
agb.Regen();

This bit of code Skins/Lofts two sketches... I suggest u link up Design Modeler to a debugger... Heres a link which might be useful:
http://www.padtinc.com/blog/post/201...ing_Part4.aspx

Best of luck

natantyt October 16, 2011 15:01

@ Dibetao

I have a similar problem in 3D. I'm trying to cut a packing of particles inside a box and mesh the remaining pore space. Do you have any advice on the implementation of this. how do you proceed with the subtraction in the gui. Cheers Pal!

dibetao October 16, 2011 19:17

@ Natantyt

I didn't find any solution for this problem using the DM (Design Modeler - Ansys 13.0). I miss GAMBIT because of its pleasant journal file (looks like a script). But the Gambit was discontinued by the Ansys team :( If you find some solution for this question/problem using the DM, please, share with us here in the forum.

ps: @rohit_8481 wrote something about this problem. However I didn't do yet.

ANT July 23, 2012 12:21

Here is the issue with this. The actual source code for these functions is (I think...) programmed in C, so they cannot be accessed directly in DesignModeler through JScripts.

However. The interface in DesignModeler, including all the clickable buttons/menus, is being generated/drawn through Javascript, which is necessary for it to function with various languages etc. without having its entire source code rewritten -- for example, if an internal function is called "CONCEPT_GIRAFFE," then they can simply use JavaScript to assign it one of many translated Strings for display in the GUI depending on the user's installation language, and when the user clicks the translated label/button, have it simply create an Event in the EventHandler that calls CONCEPT_GIRAFFE itself without depending on anything in the GUI. Similarly, someone can be programming some SAVE_USER_FILE function and program any user file selection errors to throw an exception, while the GUI/language localization team can then take the identifier of those exceptions and write translations for them that cause the resulting message to be displayed in the user's specified language ("Cannot save file to floppy drive," "Buenos dias no habla espaniol," "Je peux pas l'ecrire sur le fromage petit," etc.).

By nature of this fact, thankfully, our scripts in DesignModeler can hook into this Javascript frontend, and basically be glorified button pushers that still serve a pretty useful/effective automation routine. Problem is, with all of these functions that aren't defined in the DesignModeler Help "Scripting API" documentation, you don't have access to the functions but simply the buttons that call these functions, so programming here gets a bit creative due to the extreme lack of documentation of anything beyond the 8 simple functions listed in the Help. And by "undocumented" I mean that I haven't seen this discussed absolutely anywhere except in the context of Mechanical APDL & Workbench JScripting, which is quite different from what we need in the much-more-sandboxed DesignModeler (at least in Workbench you can record a Journal, where it stores the commands for everything you do interactively). However, using the DesignModeler's Help documentation on Scripting API as a reference to the JScript functions that you need is similarly useful to using the bible as an engineering handbook; it mentions some things that supposedly happen but doesn't describe how, it references some other things but doesn't explain how they got there, and when you try to do what it says the results usually end up skewed or backwards altogether.

In any case, as I mentioned in another post here, I was doing some searching through the ANSYS .js files for function names similar to the ones in the Help documentation to see if I could find some more of them, when I read this very intriguing line in the file agInterop.js:

Quote:

Originally Posted by agInterop.js

with (ag.wb.ScriptEngine)
{
bAddNamedItem ("ag", ag); //Provides full access, but we do not tell users about this
AddNamedItem ("agb", ag.b); //Batch command access
AddNamedItem ("agc", ag.c); //Batch constants access
RunScript (scriptPath);
}

To summarize what I said in that other post, I assume that the classes ag.b and ag.c are being clumped together as "agb" and "agc" for the purposes of limiting user Scripting control to batch commands and batch constants, and some of the *real* functions must be listed somewhere in the ANSYS directory as "ag.b.xxxxxx" and the full set of constants must be listed somewhere as "ag.c.yyyyyyyyyyy". And, sure enough, I found the two files agEventHandler.js and agConstants.js which listed a very large amount of "full access" functions and a long list of constants, respectively. Both are located in the folder "C:\Program Files\ANSYS Inc\v140\aisol\AGP\AGPages\scripts\", and you can read their contents by opening either of them with Notepad (or Notepad++, which is to Notepad what the SR-71 Blackbird is to a Cessna).

Note also that the quoted snippet above is also found in the file agMenu.js, and throws an event when the "File > Run Script" Menu item is clicked by a user in DesignModeler, except this one has the added comment: "//Change of plans! Let's run the Begin/End user script function here so it does not need to be in user scripts!" This is a good programming decision, because then the user is not awkwardly presented with any "ag.m.__________" commands at the top of their script file when the ANSYS guys are trying to sandbox JScripting in DM to "agc" and "agb" only. I don't at all mean that ANSYS is trying to keep users in the dark about these added functions, since it's probably a good idea: having "full access" to the scripts is not the best thing since it would mean they'd have to somewhat support it, and using these scripts to hook into UI elements is somewhat like building a keyboard-controlled robot whose main function is to type on a keyboard. They're somewhat difficult to control with JScript alone, without proper access to the C++ backend, by my view is, if it's there, why not use it to speed things up a bit.

Now, to get to the point about booleans, there is a command in agEventHandler.js that response to the event thrown by clicking on the Boolean button and then clicking Generate immediately after. In fact, all of the "ag.gui.xxxxxxxxx()" functions that I've tested behave this way; they run and then self-Generate immediately. When dealing with "agb.xxxxxxx" functions, you'd have to type the "agb.Regen()" method after every new Concept/Sketch/etc. that you scripted but I forgot to add the "Regen()" when using the "ag.gui.xxxxxxxxx()" methods and they worked fine. Anyways, the command is here:

ag.gui.CreateBoolean();

If you open up notepad to a blank document, paste that command in, save the document with any funky name you want but with the .js extension, then go into DesignModeler and select File > Run Script, and then browse for the file and click Open, you will see that a Boolean has been created in your Tree Outline. However, this Boolean object has nothing assigned. If you have a selection of bodies generated beforehand (I don't know how to select bodies yet, only lines & points) it will probably assign the default Unite operation and then quickly Generate itself, but there should be a way to pseudo-click the "Operation" field and select Difference, and there should definitely be a way to select Bodies (easiest way is likely through the Tree Outline, but I'll need to do some more snooping).

I am currently checking around for how to access the events thrown when a user clicks within the Details View so I can quickly assign the "Operation," "Target Body," and "Tool Bodies settings", but for now this post has gotten long enough.

P.S. If anyone else has been looking through anything I've mentioned in this post, please let me know. I'm not exactly Alan Turing here, so any help would be appreciated.

Edit: One selection function is: agb.AddSelect(type, item); where "type" is in the form of a constant from agConstants.js (e.g. ag.c.TypeVertex) and a way to assign a selected body to a variable is to use:

var body = ag.m.SelectionMgr.GetSelectedBody();

Also useful for getting various parameters are:

ag.m.SelectionMgr.getSelListSize(); //Gets number of items that are currently selected

Blunaigel April 30, 2014 07:33

Hello ANT,

have you made any progress with the boolean command.
I'm especially interested in creating a boolean operation (substract) with one target body and multiple tool bodies.


All times are GMT -4. The time now is 06:39.