Home Page > KernelCAD Models > Sections > Operations > Boolean Operations
Boolean Operations
Boolean Operations on Objects
Boolean operations on objects are: Subtraction, Intersection and Union. After
a Boolean Operation the first object always has
Mesh Section type
To perform a Boolean operations in 3D Debugger:
1. Make the first object current. In Current Object menu select the command.
2. Click on the second object in 3D View to select.
To perform Boolean subtract in Model Explorer of the component or 3D Debugger
Make the first object current using Set Current button, Select the second object
and in action menu of the explorer select Subtract. If the control key was held
just before the command the operation will include children of both objects as
if they were solids.
As objects can be easily grouped using the Join command of Model Explorer the
above allows execution of Boolean operations on groups of objects. Use
IBooolSectionEx.Execute3()
to do this from a program.
Query IBoolSection or
IBooolSectionEx
interface form the relevant ISection
to carry out Boolean operations programmatically. Note that if the original section
was not a Mesh Section the interface becomes
invalid and needs to be re-acquired before any further use.
Boolean operations with free form objects are very complicated. If you have
encountered a problem report it to DInsight and
try a workaround:
1. Change (preferably down)
geometric resolution of both objects
2. Try to shift or rotate the second object slightly if the result does not
depend on it. For example result of subtraction of a cylinder from any object
will be the same if cylinder is rotated around its axis. If above is not
possible try to shift the second object by very small amount (negligible for
your application) in several directions. For example if difference in fourth
digit does not matter for your application try shift by 1e-5. Precision of
Boolean Operations in KernelCAD is 1e-10.
IBoolSection interface also
allows performing subtraction of an infinite plane from any object. To perform
the operation:
1. Create Plane object with the help of
IDIObjectGenerator.Create (
EObjectType.eObjTypePlane ). Actual
interface type returned by the Create call is IAxis,
which represents normal of the plane, so the returned
IUnknown
can be safely cast to IAxis or IAxis can be queried from the returned
IUnknown.
The IAxis interface represents normal of the plane. To modify or retrieve
coordinates of the normal call
IAxis.SetDirection/IAxis.GetDirection.
To modify/retrieve location of the plane call
IAxis.SetLocation/IAxis.GetLocation,
which are members of the base class ILocation..
All coordinates are assumed to be global. See
Planar Ops sample for an example
2. Query ISection from the
IAxis obtained in the step 1.
3. Use ISection obtained in the step 2 as
parameter in IBoolSection.Subtract to perform the
operation.
See also BoolOp Sample
|