CFD Online Discussion Forums

CFD Online Discussion Forums (
-   ANSYS Meshing & Geometry (
-   -   [DesignModeler] Boolean Function for Script (

makkks October 22, 2012 23:16

Boolean Function for Script
Hi guys,

I was just wondering if any1 knows the function which creates BOOLEAN thru script :confused:
I checked ansys help, WB scripting but I am not able to find any function or example which depicts how to boolean bodies via script.
Please please if any1 has any idea then let me know.:D


diamondx October 23, 2012 20:58

as far as i know scripting in designmoder applies to sketches only.
Am i wrong ??

makkks October 23, 2012 21:04

Hi Diamondx,

Thanks for reply.
Well U can record only sketching bit in designmodeler but there are heaps of different function with which u can do revolve, extrude, freeze and all which you may b able to find in Ansys help.
Basically in my model , I m doing sketching, revolving, freezing then boolean and forming new part.
Other than Boolean I was able to do everything thru script.
Basically Boolean and few functions like Body operation are not documented by ansys which is stopping me to go ahead!

makkks October 25, 2012 01:08

Any1 has any idea??:(

Blunaigel April 29, 2014 09:15

Did you find any solution?
I'm looking for the same information right now.

Nigirim April 30, 2014 02:47

Hi Blunaigel and makkks,

the scriptcommand to create a boolean should be

It is not documented like many more commands.

I have never used this command before so I can only tell you it exists but not how it works.

If I find something else I will edit it in this post.


Kapi November 6, 2014 18:19

Nigirim you are right.

To create Boolean function


and to access the item in it, you have to use listview like


ag.listview.ActivateItem("Tool Bodies");
once you have activated this item you can select body and "Apply" similarly.

Hope this helps

giacoppo November 9, 2016 14:05

design modeler boolean operation via script
I'm facing the geometry modeling trhough design modeler scripting..
I need some help to make boolean operation between bodies...
particularly I used the
ag.gui.CreateBoolean() command but I have some trouble in how select target and tool bodies...
Anyone can help me?

Kapi November 9, 2016 17:59

Hey mate,

you gotta do named selection of those bodies first then use below code
for ex: boolean substract body1 from all bodies:


var fBoolean = ag.gui.CreateBoolean();
fBoolean.Operation = 2;
ag.listview.ActivateItem("Tool Bodies");
ag.listview.ItemValue = "Apply";
ag.listview.ActivateItem("Target Bodies");
agb.AddSelect(agc.TypeBody, body1);
ag.listview.ItemValue = "Apply";
var finalbody = agb.FormNewPartFromAllBodies(); = "Final_Body1";

where "body1" is named selection of substracted body.

hope it helps


giacoppo November 10, 2016 05:13

thank you Kapi,
It helped me to make a step forward...
now the problem is how to select bodies via scripting?


giacoppo November 10, 2016 07:01

dear Kapi,
I tried to implement your script after defining manually the named selection but I get the error:
body1 not defined error 800a1391 Jscript run time error...
any suggestion?

giacoppo November 10, 2016 12:33

Thanks to your Advice I got into the script and I found an interesting solution for selecting bodies in the treeview: here is the working script.

var fBoolean = ag.gui.CreateBoolean(); //Create a Boolean operation
fBoolean.Name="a_collector";//Assign a Name to the Boolean feature
fBoolean.Operation = 2; //Select the Boolean operation 1 for UNite 2 for Subtract
//3 for Intersect and 4 for Imprint Faces
fBoolean.Preserve=ag.c.Yes; //Specify if preserve tool bodies or not
ag.listview.ActivateItem("Target Bodies"); //Activate Target Bodies Item
agb.ClearSelections(); //now we start with the selection of bodies involved in the boolean
body =; //use the identifier to access/modify bodies
agb.AddSelect(agc.TypeBody, body)
ag.listview.ItemValue = "Apply";
ag.listview.ActivateItem("Tool Bodies");
for (var i = 7; i<=9; i++){ //perform multiple selection
body =;
agb.AddSelect(agc.TypeBody, body) }
ag.listview.ItemValue = "Apply";
I hope it helps

Kapi November 10, 2016 17:42

glad it worked for you

giacoppo November 11, 2016 08:30

Hello Dear,
Anyone know how silently accept the Warning pop-up "feature cannot be copy of another feature name, so modified number at end" .
or in general how overcome this warning?

giacoppo November 11, 2016 11:48

the problem was due to same name assigned to different features...

All times are GMT -4. The time now is 07:27.