UnionSelection, IntersectionSelection, DifferenceSelection, ComplementSelection
Combine selections of entities or objects using a Boolean operation.
Syntax
model.component(<ctag>).geom(<tag>).create(<ftag>,"UnionSelection");
model.component(<ctag>).geom(<tag>).create(<ftag>,"IntersectionSelection");
model.component(<ctag>).geom(<tag>).create(<ftag>,"DifferenceSelection");
model.component(<ctag>).geom(<tag>).create(<ftag>,"ComplementSelection");
model.component(<ctag>).geom(<tag>).feature().set(property,<value>);
model.component(<ctag>).geom(<tag>).feature().getType(property);
Description
Use UnionSelection to get all entities/objects that belong to at least one of the input selections. Use IntersectionSelection to get all entities/objects that belong to all input selections. Use DifferenceSelection to get all entities/objects that belong some of the add selections, but do not belong to any of the subtract selections. Use ComplementSelection to get all entities/objects of the given dimension that do not belong to any input selection.
For DifferenceSelection, the following properties are available:
none | custom | integer between 1 and the number of colors in the current theme
The color to use. Active when color is set to custom.
-1 | 0 | 1 | 2 | 3
on | off
on | off
For the other selections, the following properties are available:
none | custom | integer between 1 and the number of colors in the current theme
The color to use. Active when color is set to custom.
-1 | 0 | 1 | 2 | 3
on | off
If the level is not Object, the allowed values are on | off. If the level is Object, the allowed values are all | obj | dom | bnd | edg | pnt | off.
If the level is not Object, the default value is on. If the level is Object, the default value is all in a component’s geometry, obj in a part, and dom in a work plane’s Plane Geometry.
See Selections of Geometric Entities for general information about selections.
Example
In an array of blocks, select all vertices whose distance to the origin is between 2.5 and 3.5. This results in 22 vertices in 7 different objects.
Code for Use with Java
Model model = ModelUtil.create("Model");
model.component().create("comp1");
GeomSequence g = model.component("comp1").geom().create("geom1", 3);
g.create("blk1", "Block");
g.create("arr1", "Array");
g.feature("arr1").selection("input").set("blk1");
g.feature("arr1").set("size", new int[]{3,3,1});
g.feature("arr1").set("displ", new double[]{1.5,1.5,0});
g.run("arr1");
g.create("ballsel1","BallSelection");
g.feature("ballsel1").set("entitydim", 0);
g.feature("ballsel1").set("r", 3.5);
g.feature().duplicate("ballsel2","ballsel1");
g.feature("ballsel2").set("r", 2.5);
g.create("difsel1", "DifferenceSelection");
g.feature("difsel1").set("entitydim", 0);
g.feature("difsel1").set("add", new String[]{"ballsel1"});
g.feature("difsel1").set("subtract", new String[]{"ballsel2"});
g.run("difsel1");
String[] obj = g.selection("difsel1").objects();
int nVtx = 0;
for (int i=0; i<obj.length; ++i)
  nVtx += g.selection("difsel1").entities(obj[i],0).length;
// obj.length = 7, nVtx = 22
Code for Use with MATLAB
model = ModelUtil.create('Model');
model.component.create('comp1');
g = model.component('comp1').geom.create('geom1', 3);
g.create('blk1', 'Block');
g.create('arr1', 'Array');
g.feature('arr1').selection('input').set('blk1');
g.feature('arr1').set('size', [3,3,1]);
g.feature('arr1').set('displ', [1.5,1.5,0]);
g.run('arr1');
g.create('ballsel1','BallSelection');
g.feature('ballsel1').set('entitydim', 0);
g.feature('ballsel1').set('r', 3.5);
g.feature.duplicate('ballsel2','ballsel1');
g.feature('ballsel2').set('r', 2.5);
g.create('difsel1', 'DifferenceSelection');
g.feature('difsel1').set('entitydim', 0);
g.feature('difsel1').set('add', {'ballsel1'});
g.feature('difsel1').set('subtract', {'ballsel2'});
g.run('difsel1');
obj = g.selection('difsel1').objects;
nVtx = 0;
for i=1:length(obj)
  nVtx = nVtx + length(g.selection('difsel1').entities(obj(i),0));
end
% length(obj) = 7, nVtx = 22
See Also
AdjacentSelection, BallSelection, BoxSelection, CylinderSelection, Disk Selection, ExplicitSelection