# Form and Space

## creating CG 3D since 2001

• Connect @
• Vimeo

#### MEL: Booleans

Matthew | February 27, 2013

Like I’ve said in class, booleans are rarely taught for a few reasons, and there’s even a piece of literature in my library about digital modeling with a chapter titled, “Booleans Are Evil”. Well, for a long time, I thought that too, but not because I couldn’t use them, or that other artists shouldn’t use them, but because it’s difficult to explain there use. There are problems that arise when using booleans, but with a little foresight, edge loop planning, the boolean can be very powerful and assist with very complex geometric problems. Traditionally a boolean modeling operation is between object A and object B. With this script you will be able to boolean together more than two objects at a time. It will iterate through your selection, creating a final boolean object. The default settings are set to a Union boolean, and a Merge tolerance of 0.001.

16 Tori Booleaned together in about one second.

The image above is a simple 2d array of 8 sided tori rotated on the Y axis at 22.5 degrees. They are spaced with just the right amount of overlap so no triangles form after the boolean; 16 objects booleaned together in a few seconds.

``` ```
``````
/*----------------------
Author Matthew L. Stoehr
formandspace.com
mattstoehr@gmail.com
mls_booleanMulti
version 0.1
2-26-2013

Boolean more than two
polygon meshses at once.

Select poly meshes to
boolean, and run.

----------------------*/

mls_booleanMulti(1, 0.001);

proc mls_booleanMulti(int \$_operation, float \$_tolerance)
{
float \$tolerance = \$_tolerance;
float \$operation = \$_operation;

string \$sel[] = `ls -selection`;
string \$newSel[] = `ls \$sel[0] \$sel[1]`;
string \$boolObject[];

int \$count = size(\$sel);
int \$i;
int \$h = 2;

for(\$i=0; \$i < \$count-1; \$i++)
{
\$boolObject = `polyBoolOp
-op \$operation
-ch 0
\$newSel[0] \$newSel[1]`;

if(\$h < \$count){
\$newSel = `ls -sl`;
\$h++;
}else{
print "I'm done!";
}
}
polyMergeVertex -d \$tolerance -am 1 -ch 1 \$boolObject;
select -r \$boolObject;
}

``````