CFD Online Discussion Forums

CFD Online Discussion Forums (
-   ANSYS Meshing & Geometry (
-   -   [DesignModeler] DesignModeler Scripting: How to get Full Command Access (

ANT July 23, 2012 11:13

DesignModeler Scripting: How to get Full Command Access
I've spent the past several days trying to understand the DesignModeler Script programming interface in order to automate some very iterative geometry generation, which has been quite the difficult process since the Help documentation (DesignModeler User Guide > Scripting API) provides an extremely limited explanation of only a few basic functions. It limits what you can do to only a few batch commands like generating points, planes, sketches, etc., and is missing some pretty essential functions (e.g. how does one generate a Boolean? How does one select objects? How does one create a Named Selection, and how does one choose what goes in the named selection?).

This API also mentions parameters for which the creation/selection commands are undocumented (e.g. explanation of the agb.Sweep(...) command states that it can accept a Named Selection as a Profile or Path parameter, but does not explain how a Named Selection can be specified or generated). Moreover, most tutorials/forum posts on the matter describe only JScript programming for the Workbench/Mechanical environments, which are difficult to follow and simply do not apply to the different API/commands required for DesignModeler.

I noticed that the help documentation instructs users to use the "agc." prefix for "Script Constants" (e.g. agc.Yes, agc.Frozen, agc.TypeEdge3d, etc.) and the "agb." prefix for "application functions":


Originally Posted by ANSYS DesignModeler User Guide > Scripting API
Access to the DesignModeler application functions is accessible via the prefix 'agb.', as in the command: var LF1 = agb.LinePt();

As recommended in various guides, I thought I'd search the ANSYS directory for some added functions that are unlisted in the DesignModeler API. After some fruitless searching, I stumbled upon the file "agInterop.js," in which this snippet was most significant:


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);

From the bolded line above, we learn that there are commands using the prefix "ag." that give full access, but users aren't told about this. Then, from the next two lines, we learn that the prefix "agb" is a replacement for the prefix "ag.b." and, likewise, that "agc" is a replacement for "ag.c.".

In the same folder as agInterop.js exists a file called agConstants.js, in which you can see that the 9 script constants are just a small subset of the many, many more that exist.

Searching for "ag." in the ANSYS directory yields the useful file "agEventHandler.js" which is full of useful commands. Below are a few of the categories of these commands:* --> Graphics Handler/Service ("AgmService") commands
ag.gui.* --> GUI commands (GUIModeler), a command for every button shown in DesignModeler (for example ag.gui.AddSketch() and ag.gui.CreatePlane() ), and some others
ag.m.* --> Modeler, Main, or Menu (?) commands (e.g. ag.m.SuppressBody(), ag.m.DisplayBodyErrors(...), etc.)

Since I just found this, I'm still trying to dig around and learn how to use all of this, but I thought I'd post here since I haven't found anything online that describes these extra functions & where they're at least named within .js files in the ANSYS directory. However, below is an example of a useful way to generate first a separate named selection for each edge in a group (with sequential Face IDs, generated e.g. via AddSegment(...) method on a LinePt() instance; total number defined by numLines, which we assume has been assigned already), and then a named selection that contains all of the edges:


for (var i = 1; i<= numLines; i++) {
        ag.gui.ClearSelect(); //Clears the selection
        ag.b.AddSelectEdgeID(i); //Picks the edge ID corresponding to i on each iteration of the for-loop
        ag.gui.CreateSelectionSet(); //Generates the Named Selection from selection (the one line)

ag.gui.ClearSelect(); //Clears the selection
for (var i = 1; i <= numLines; i++) {
        ag.b.AddSelectEdgeID(i); //Adds all of the edges with edge IDs 1 through numLines to selection
ag.gui.CreateSelectionSet(); //Generates the Named Selection from selection (the group of lines)

Hope this is helpful for some! I will keep adding to this post as I continue to hunt through functions recursively until I find a .js file etc. where they're at least partially defined/explained/used.

Edit: List of Global Handles (from agMain.js file)

// The most noteworthy global handles are:
// ag.wb ....................... WorkBench object
// ag.silent ................... No popup messages if set to true
// ag.guiScript ................ A pointer to <this> scripting engine
// ag.fs ....................... Scripting.FileSystemObject
// ag.regName .................. Applet's (registry) name
// ag.regNameDS ................ DesignSpace Applet's (registry) name
// ag.installDir ............... InstallDir path
// ag.pagesDir ................. Pages directory
// ag.stringTable .............. Localized stringtable
// ag.imageList* ............... The imagelist(s)
// ag.runnigScriptPath ......... See agRunScript(.)
// ag.m ........................ AGP's Modeler object
// ....................... AGP's FeatureMgr object
// ag.b ........................ AGP's BatchMgr object
// ag.WB2....................... True if launched from WB2
// ag.gui ...................... AGP's GUIModeler object
// ....................... AGP's GfxService object
// ag.fromDS ................... true iff started from DS
// ag.cursorWaitCounter......... counter, 0 when not waiting
// ag.printPreviewTabClicked.... true when user clicks Print Preview tab
// ag.printPreviewActive........ true when Print Preview Window is active

Searching within files in the ANSYS install directory with selections from this (like "ag.gui." or "ag.m.") will probably get you some useful results.

Edit 2: This file (agMain.js) also includes:


Originally Posted by agMain.js
// The one and only global AG object
// (All global handles are in stored as its 'expando' properties)

// However, there are several globals related to the WorkBench (wb*)
var ag = new Object();

BaoBab May 28, 2014 09:42

some more "revrse engineering"....
I've used "ole/com object viewer" from Microsoft Visual Studio SDK (OleView.exe) and inspected Type Libraries from

located at "C:\Program Files\ANSYS Inc\v150\aisol\bin\winx64\"

Refer to IAnsBatchMgr Interface definition for all ag.b functions available.
Same thing with IAnsGUIModeler and its ag.gui JScript analog.

There are sooo many other interesting things (not documented yet)!
But it's good enough source for those who has programmer experience. works!

Some examples:

// ag.wb........................IWB
// ag.agApplet................IAGApplet       
// ag.m ........................IAnsGeomModeler 
// .......................IAnsFeatureMgr 
// ag.b .........................IAnsBatchMgr   
// ag.gui .......................IAnsGUIModeler 
// ........................IAnsGfxService 
// browse the body list
for (var i = 0; i <; i++)
    var;  //это объект IAnsBody
  ag.gui.DisplayWarning("Body "+i+" has"
// browse the feature list (operations)
for (var i = 0; i <; i++)
      ag.gui.DisplayWarning("Feature "+i+" has "+f1.NumChildren+" childs and"
      for (var ii = 0; ii < f1.NumChildren; ii++)
            var ff1=f1.Child(ii);
            ag.gui.DisplayWarning("Feature "+i+"."+ii+" has"
// useful function to understand the FeatureType()
function strFType(ft)
{ var sName="undefined";
    {  case 2001: sName="ANS_FEATURE_PLANE          ";break;
          case 2002: sName="ANS_FEATURE_SKETCH        ";break;
          case 2003: sName="ANS_FEATURE_EXTRUDE        ";break;
          case 2004: sName="ANS_FEATURE_REVOLVE        ";break;
          case 2005: sName="ANS_FEATURE_BLEND          ";break;
          case 2006: sName="ANS_FEATURE_FBLEND        ";break;
          case 2007: sName="ANS_FEATURE_VBLEND        ";break;
          case 2008: sName="ANS_FEATURE_CHAMFER        ";break;
          case 2009: sName="ANS_FEATURE_SWEEP          ";break;
          case 2010: sName="ANS_FEATURE_SKIN          ";break;
          case 2011: sName="ANS_FEATURE_WIRE          ";break;
          case 2012: sName="ANS_FEATURE_UNFREEZE      ";break;
          case 2013: sName="ANS_FEATURE_FREEZE        ";break;
          case 2014: sName="ANS_FEATURE_PART          ";break;
          case 2015: sName="ANS_FEATURE_IMPORT        ";break;
          case 2016: sName="ANS_FEATURE_ATTACH        ";break;
          case 2017: sName="ANS_FEATURE_DELETE_FACES  ";break;
          case 2018: sName="ANS_FEATURE_ROLLMARK      ";break;
          case 2019: sName="ANS_FEATURE_SHELL          ";break;
          case 2020: sName="ANS_FEATURE_SPOT          ";break;
          case 2021: sName="ANS_FEATURE_SLICE          ";break;
          case 2022: sName="ANS_FEATURE_BODYOP        ";break;
          case 2023: sName="ANS_FEATURE_WIRETOOL      ";break;
          case 2024: sName="ANS_FEATURE_LINEPT        ";break;
          case 2025: sName="ANS_FEATURE_LINESK        ";break;
          case 2026: sName="ANS_FEATURE_LINEED        ";break;
          case 2027: sName="ANS_FEATURE_SELECTION_SET  ";break;
          case 2028: sName="ANS_FEATURE_JOINT          ";break;
          case 2029: sName="ANS_FEATURE_SURFACE_EXT    ";break;
          case 2030: sName="ANS_FEATURE_SKETCH_INSTANCE";break;
          case 2031: sName="ANS_FEATURE_ENCLOSURE      ";break;
          case 2032: sName="ANS_FEATURE_SURFACE_PATCH  ";break;
          case 2033: sName="ANS_FEATURE_SURF_SK        ";break;
          case 2034: sName="ANS_FEATURE_MIDSURF        ";break;
          case 2035: sName="ANS_FEATURE_FILL          ";break;
          case 2036: sName="ANS_FEATURE_CURVE          ";break;
          case 2037: sName="ANS_FEATURE_PATTERN        ";break; 
          case 2038: sName="ANS_FEATURE_WINDING        ";break;
          case 2039: sName="ANS_FEATURE_SAMPLE        ";break;
          case 2040: sName="ANS_FEATURE_IC_MANAGER    ";break;
          case 2041: sName="ANS_FEATURE_IC_POSTMGR    ";break;
          case 2042: sName="ANS_FEATURE_IC_PRE_MANAGER ";break;
          case 2043: sName="ANS_FEATURE_PRIMITIVE      ";break; 
          case 2044: sName="ANS_FEATURE_THIRDPARTY    ";break;
          case 2045: sName="ANS_FEATURE_SYMMETRY      ";break;
          case 2046: sName="ANS_FEATURE_SOLID_EXT      ";break;
          case 2047: sName="ANS_FEATURE_SHELLPRIMITIVE ";break;
          case 2048: sName="ANS_FEATURE_BOOLEAN        ";break;
          case 2049: sName="ANS_FEATURE_VERTEX_BLEND  ";break;
          case 2050: sName="ANS_FEATURE_UNIVERSE      ";break;
          case 2051: sName="ANS_FEATURE_LATTICE        ";break;
          case 2052: sName="ANS_FEATURE_SKETCH_PROJECT ";break;
          case 2053: sName="ANS_FEATURE_FLIP          ";break;
          case 2054: sName="ANS_FEATURE_CYCLIC_SYMMETRY";break;
          case 2055: sName="ANS_FEATURE_MERGE          ";break;
          case 2056: sName="ANS_FEATURE_CONNECT        ";break;
          case 2057: sName="ANS_FEATURE_REPAIR        ";break;
          case 2058: sName="ANS_FEATURE_ATTRIBUTE      ";break;
          case 2059: sName="ANS_FEATURE_FINALIZE      ";break;
          case 2060: sName="ANS_FEATURE_PROJECTION    ";break;
          case 2061: sName="ANS_FEATURE_DELETE_EDGES  ";break;
          case 2062: sName="ANS_FEATURE_ICESIMPLIFY    ";break;
          case 2063: sName="ANS_FEATURE_ICEFAN        ";break;
          case 2064: sName="ANS_FEATURE_ICEOPENING    ";break;
          case 2065: sName="ANS_FEATURE_CONVERSION    ";break;
          case 2066: sName="ANS_FEATURE_SURF_FROM_FACES";break;
          case 2067: sName="ANS_FEATURE_FACE_SPLIT    ";break;
          case 2068: sName="ANS_FEATURE_ICEGRILLE      ";break;
          case 2069: sName="ANS_FEATURE_SHAFT          ";break;
          case 2070: sName="ANS_FEATURE_FEATURE_GROUP  ";break;
          case 2071: sName="ANS_FEATURE_ICEENCLOSURE  ";break;
    return sName;
// Also we can use Tree control for browsing
// ag.mROOT = "-*ROOT*-";
// ag.bROOT = "-*BODYROOT*-";
// ag.cROOT = "-*SECTIONROOT*-";
// ag.uROOT = "-*UNIVERSEROOT*-";
//  ag.tree ................ IWBTreeViewCtrl


function browseDown(node,level)
      var myNode=node;  // IWBTreeNode
      while(myNode != null)
            ag.m.DisplayMessage("Node level "+level+
            "\nText ="+myNode.Text+
            "\nKey = "+myNode.Key,0);
            if(myNode.Children>0) browseDown(myNode.Child,level+1);
            myNode = myNode.Next;

yavuz.hspc June 6, 2014 03:59

It's nice to see a recent update on the most visited page after searches like "Design Modeler Scripting API" . Both contributions help a lot. Thank you very much.

BaoBab June 6, 2014 04:35

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


// start from clear scratch
ag.m.NewSession (true);
ag.gui.setUnits(ag.c.UnitMillimeter, ag.c.UnitDegree, ag.c.No);

// import file
var imp1=ag.b.Import("myFile.igs");  // IAnsImport


// get the actual model bounds
var medges=ag.m.ModelEdges(); // IAnsEdges3D
var maxX=0, minX=0 , maxY=0, minY=0 , maxZ=0, minZ=0;
for(var i=1;i<= medges.Count;i++)
  var eg=medges.Item(i);  // IAnsEdge3D
  if(eg.EdgeCoord(0)>maxX) maxX=eg.EdgeCoord(0);
  if(eg.EdgeCoord(0)<minX) minX=eg.EdgeCoord(0);
  if(eg.EdgeCoord(1)>maxY) maxY=eg.EdgeCoord(1);
  if(eg.EdgeCoord(1)<minY) minY=eg.EdgeCoord(1);
  if(eg.EdgeCoord(2)>maxZ) maxZ=eg.EdgeCoord(2);
  if(eg.EdgeCoord(2)<minZ) minZ=eg.EdgeCoord(2);

// create scetch object
var bX=(maxX+minX)/2.0*1e3;  // EdgeCoord() gives "m" but we need 'mm'
var bY=(maxY+minY)/2.0*1e3;
var lX=Math.abs(maxX-minX)*1e3+4; // add 2 mm to each bound
var lY=Math.abs(maxY-minY)*1e3+4;

var skPlane  = ag.b.GetXYPlane(); // IAnsPlane
var Sk1 = skPlane.NewSketch();  // IAnsSketch
Sk1.Name = "base_sketch";
Sk1.Line(bX-lX/2.0, bY-lY/2.0, bX+lX/2.0, bY-lY/2.0);
Sk1.Line(bX+lX/2.0, bY-lY/2.0, bX+lX/2.0, bY+lY/2.0);
Sk1.Line(bX+lX/2.0, bY+lY/2.0, bX-lX/2.0, bY+lY/2.0);
Sk1.Line(bX-lX/2.0, bY+lY/2.0, bX-lX/2.0, bY-lY/2.0);

// NOTE how to select sketch before CreateSurfSk feature !!!
ag.selectedFeature = ag.gui.TreeviewFeature(Sk1.Name, 0);
var SSk1=ag.gui.CreateSurfSk();  // IAnsFSurfSk

Jaggs July 28, 2014 08:26

Design Modeler listing operations of a selected object
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. How can we list down all the operations (like Boolean, body operations etc.) performed on a selected object?

BaoBab July 30, 2014 05:11


Originally Posted by Jaggs (Post 503426)
How can we list down all the operations (like Boolean, body operations etc.) performed on a selected object?

I have found that the .Label property of the IAnsBody object starts with the .FeatureID of the ''parent" feature. (see how to browse body and feature objects in posts above).

In regard to selected objects which were used for the feature creation, I can get the total number (own property in each feature), but not object handles.

vigges August 9, 2014 02:10

Hello Alexander,

you seem to have some experience with JSript quirks of DesignModeler, maybe you can enlighten me :-)

My task is actually pretty simple. I'd like to create a sketch, consisting of three lines (bottom, left, right) and an arc (top). At the intersections of the arc with the left and right line, fillets with a 3mm radius shall be created.

What I have so far:


function planeSketch (p)
  p.Plane  = agb.GetYZPlane();
  p.Origin = p.Plane.GetOrigin();
  p.XAxis  = p.Plane.GetXAxis();
  p.YAxis  = p.Plane.GetYAxis();

  p.Sk = p.Plane.newSketch();
  p.Sk.Name = "TEST";

  with (p.Sk)
    p.Ln1_1 = Line(x1, y1, x2, y2);  // bottom
    p.Ln1_2 = Line(x2, y2, x3, y3);  // right
    p.Ln1_3 = ArcCtrEdge(xCtr, yCtr, x3, y3, x4, y4);  // arc
    p.Ln1_4 = Line(x4, y4, x1, y1);  // left
    p.Ln1_5 = Fillet(p.Ln1_2, selx1, sely1, p.Ln1_3, selx2, sely2, 3., agc.Yes);  // right fillet
    p.Ln1_6 = Fillet(p.Ln1_3, selx1, sely1, p.Ln1_4, selx2, sely2, 3., agc.Yes);  // left fillet
var ps = planeSketch (new Object());

When I call the script file, all planes (not listed here), the three lines and the arc are created. But reaching the statement for the first fillet, I get an error 80004005 without description.

Do you have any ideas what's causing this behavior?

Best regards,

BaoBab August 13, 2014 07:02

IAnsSketch::Fillet() fail error
Here is the definition of IAnsSketch::Fillet() from Ans.Modeler.ObjectsCOM.dll :


[id(0x0000006c), helpstring("Creates a round corner between two curves. Locations and switches determine if and how to trim")]
        HRESULT Fillet(
                        [in] IAnsEdge* edge1,
                        [in] double selPt1_x,
                        [in] double selPt1_y,
                        [in] IAnsEdge* edge2,
                        [in] double selPt2_x,
                        [in] double selPt2_y,
                        [in] double Radius,
                        [in] int trim,
                        [out, retval] IAnsEdge** newFilletId);

So, the error code (HRESULT)0x80004005 can have the meaning of E_FAIL (as defined in WinError.h from Windows SDK). Now, why it can happen?...Most possible reason is wrong arguments which leads to wrong result shape.
The following code works good but the second fillet extra edges are not trimmed (do not know why):


// Plane sketch
var myPlane=agb.GetXYPlane();
var Sk1 = myPlane.NewSketch();
//Sk1.Name = "Sketch1";

// Points location
var x_low=-5.0;
var x_high=15.0;
var y_low=-1.0;
var y_high=19.0;
var x_arc=(x_low+x_high)/2;
var y_arc=4.0;
var r_arc=Math.sqrt((x_high-x_arc)*(x_high-x_arc)+(y_high-y_arc)*(y_high-y_arc));

var bottomLn = Sk1.Line(x_low, y_low, x_high, y_low);
var leftLn = Sk1.Line(x_low, y_low, x_low, y_high);
var rightLn = Sk1.Line(x_high, y_low, x_high, y_high);
var anArc= Sk1.ArcCtrEdge(x_arc, y_arc, x_high, y_high, x_low, y_high);
var filArc1=Sk1.Fillet( leftLn, x_low, y_high-0.5, anArc, x_arc, y_arc+r_arc, 3.0, 4);
var filArc2=Sk1.Fillet( rightLn, x_high, y_high-0.5, anArc, x_arc, y_arc+r_arc, 3.0, 4);


As far I understand the Pt1 on line segment and Pt2 on arc segment must reflect the trimming direction.

As you can also see the special object wrapper around shape construction (as in "WriteScript:Sketches" command) is optional.

HA11 September 2, 2014 03:48

command geometry generation based on Ansys functions
Hello Guys,

Really useful info... :) thanks
Is there any way to get this command geometry generation based on Ansys functions automatically from Ansys? I mean I generate my 3D model in Design Modeler GUI, but I want to export it in text command style not in .agdb format, So I can modify the geometry by modifying the command text file.

Nigirim September 2, 2014 04:42

Hello HA11,

unfortunately you can't let ANSYS generate such a file, you will have to write it on your own. The only thing that works automatically are sketches.


BaoBab September 3, 2014 04:05

JScript-Python-APDL interconnection

Originally Posted by HA11 (Post 508762)
...I mean I generate my 3D model in Design Modeler GUI, but I want to export it in text command style not in .agdb format, So I can modify the geometry by modifying the command text file.

I've solved the similar task in the following way:

1) there is a JScript for DM (let say "geom.js") which creates the model geometry and then export geometry into IGES/STEP.
2) there is the IronPython script (let say "update_geom.wbjn") for WB to open/create a project, insert "geometry" template, open it and run geom.js file there.
3) there is APDL-script (let say "import_geom.inp") to import IGES/STEP in ANSYS APDL.
4) there is system BAT-file to run WB in batch mode with update_geom.wbjn as the parameter and then the ANSYS APDL in GUI mode with import_geom.inp as the parameter.

Here is the wbjn-code snippet

# encoding: utf-8

# this is to log errors in external file
import clr
import System.Windows.Forms as WinForms
logFile = open(logPath,

errNum = 0

    # in case we need Static Structural further
  template1 = GetTemplate(TemplateName="Static Structural", Solver="ANSYS")

  # open geometry
  geometry1 = system2.GetContainer(ComponentName="Geometry")
  geometry1.SendCommand( Command = """
    myParams      = new Object();
    myParams.fName = "some_data_file_if_needed_in_script.txt";
    var scriptPath="geom_script.js";
  # need this to run JScript inside DM properly
    function runIt(path)
    { ag.m.BeginUserScript();
      try{ ag.runningScriptPath = path;
        ag.wb.ScriptEngine.AddNamedItem ("ag", ag);
        ag.wb.ScriptEngine.AddNamedItem ("myParams", myParams);
      catch(e){ag.m.DisplayMessage("Error in JScript-> " +path,2);}
except Exception, err:
  logFile.write("Error:\n%s\n\n" % err)
# save project if needed
Save( FilePath="project_file.wbpj",

# log all the WB messages
for msg in GetMessages():
  msgString =msg.MessageType + ":\n" + msg.Summary + "\n\n"


if errNum > 0:
 WinForms.MessageBox.Show("some text about log-file created:\n%s" % logPath, "Error caption")

uqzcpo September 22, 2014 09:20

about command line in designmodeler
Helle everyone! I need to use DesignModeler to conduct a multidisciplinary optimiziation for a radial-inflow turbine rotor. But I came across several problems:
This figure shows what I do through the DesignModeler Graphic user interface, I import a .BGD file which is generated from the BladeGen module firstly, and then I conduct Blend and Cut material. I have a lot of different but similar .BGD files, so what I want to do is changing the ImportBGD1 item in the Tree Outline (red rectangle).
And change the ImportBGD1 item to another .BGD file like the figure shows below. And Generate at last, then all the steps will be carried out on the new .BGD object. I have tried through the Graphic user interface and succeed. Now I hope all of these can be conducted through the js script. I look for some command lines for the DesignModeler, but I can not find the command correspond to the “replace the ImportBGD1 item”. I attach the workbench project files below (, and hope you guys can help me! Thank you very much!

I thought the command may be ag.GUI.CreateImportBGD('file path'), but it is not.

In the dir: v145\aisol\BladeModeler\BladeEditor\BMPages\script s, there is a bmScriptInt.js file, and a function called CreatImportBGD(), how to use it?

BaoBab September 23, 2014 02:50

Unfortunately I have no blade generator and corresponded DM import plug-in installed. However, I have found that the BGD-import feature has IAnsFThirdPartyHost object type.
The IAnsFThirdPartyHost does not support any 'source geometry' property (like IAnsImport::SourceName), but, maybe SetParameter() function can be helpfull:

HRESULT SetParameter(
                        [in] BSTR propname,
                        [in] BSTR dimName,
                        [in] BSTR typeName,
                        [in] BSTR minDef,
                        [in] BSTR minVal,
                        [in] BSTR maxDef,
                        [in] BSTR maxVal,
                        [in] BSTR paramName,
                        [in] VARIANT_BOOL checked);

vigges October 30, 2014 07:21

Hello all,

my JScript file generating all the geometric entities and named selections for further use in CFX Pre is done. To get there, I had to implement a variety of ag.gui.CreateXYZ and other ag.gui commands.

I bet you all know the feeling, when, after a long time of trying different things, something is finally working... :)

I'm on Linux, so I run "runwb2 -B -R geometry.wbjn" with the following journalfile:

# encoding: utf-8
template1 = GetTemplate(TemplateName="Geometry")
system1 = template1.CreateSystem()
geometry1 = system1.GetContainer(ComponentName="Geometry")
script = open('/path/to/my/script.js', 'r')

At some point DesignModeler pops up, and I can literally watch my JScript-Code being processed. When it's done, the DM window closes and the project is being saved as stated in the journal file.

So far, so good...

Unfortunately, the final project is supposed to be running on a HPC system entirely without GUI. So, when I test the script in Terminal Mode (Ctrl-Alt-F1), apart from the error message "Cannot open x display (not specified)", I get a script error message regarding the ag.gui code snippets. It makes sense to me, because all those ag.gui objects depend on the gui stuff being loaded. And that's not going to happen when there is window.

What I thought about is to pipe the request for a display to another, virtual display which does not need to pop up. Maybe one of you has already run into that wall and figured out how to tear it down ;)

Best regards

Solved the problem using TightVNC.
Step 1: Create virtual display

vncserver -geometry 1920x1080 :10
Step 2: Export display variable

export DISPLAY=:10
Step 3: Run WB

runwb2 -B -R geometry.wbjn
Step 4: Be happy!!!

stessigunn March 25, 2015 09:15

3D curve

Do you know if it is possible to write a script to import a 3D curve?

EDIT: This seems to do the job:
var NL1 = ag.gui.CreateCurve();
NL1.Name = "Name";
NL1.CoordinateFile = "FilePath";

But now I have a problem as I am trying to script a skin feature between the curves. Does anyone know how to select 3D curves with the script? I guess I can use this command to create the feature: agb.Skin(agc.Add, agc.No, 0.0, 0.0), but I haven't figured out how to select the profiles.

Kapi March 29, 2015 20:15

Hi SG,

Please don't post same question in different Threads.
Check other thread for reply.


vigges May 22, 2015 13:39

Hey guys,

does anybody happen to know how to access the entities stored in a Named Selection within DesignModeler? All I've been able to accomplish sofar was to get the count of stored entities.

Have a nice weekend!

Kapi May 24, 2015 18:39

Hi Victor,

Yes, You can access entities stored in NS
Could you please elaborate your question bit more? and also post your code you have got so far?


vigges May 25, 2015 10:24

Hello KAPI,

I processed all faces in my multi part model and assigned them to their respective NSs, i.e. Part1ToPart2 and Part2ToPart1 which contain faces Part1 and Part2 have in common.
In a further step I'd like to refine this selection, like Part1ToPart2Axial (and vice versa) and Part1ToPart2Circumferential (and vice versa).
For that, I'd like to consider only the faces already assigned to the base selections Part1ToPart2 (and vice versa). But I lack the knowledge how to "grab" the items of one NS.

This is how I create the NS objects:

Part1ToPart2 = ag.gui.CreateSelectionSet();

I know, I probably could achieve all that within Ansys Meshing/DS, but I'd like to do that within DesignModeler.

Thanks for your input.
Best regards,

Kapi May 25, 2015 19:46

Hi Victor,

Try to use the below code to pick NS and see if it works

agb.AddSelect(agc.TypeFace, Part1ToPart2);

Change "Part1ToPart2" to whatever your NS is. If it dosent work then add this above AddSelect

Hope it helps

All times are GMT -4. The time now is 23:11.