Show / Hide Table of Contents

Boolean Operations

This example provides information on using boolean operations in RobotStudio. First create a box and a cone. Then use these bodies to create three new bodies; an intersection between the box and the cone; cut the box from the cone; and join the box with the cone.

Go to the Modeling browser, and expand My_Part to see all the bodies. It might be easier to see the different bodies if you first make them invisible, and then make them visible one at a time.

Use this procedure to perform Boolean operations:

  1. Create Part object to contain the Bodies and Add it to the Station

  2. Create a solid box

  3. Create a cone

  4. Boolean Operations

    • Create the intersection between the box and the cone

    • Cut the cone with the box

    • Join(Body) the box and the cone

Solution

  1. Create Part object to contain the Bodies and Add it to the Station

    Part p = new Part();
    p.Name = "My_Part";
    station.GraphicComponents.Add(p);
    
  2. Create a solid box

    Matrix4 matrix_origo = new Matrix4(new Vector3(Axis.X), 0.0);
    Vector3 size = new Vector3(0.5, 0.5, 0.5);
    Body box = Body.CreateSolidBox(matrix_origo, size);
    box.Name = "Box";
    p.Bodies.Add(box);
    
  3. Create a cone

    Body cone = Body.CreateSolidCone(matrix_origo, 1.0, 1.0);
    cone.Name = "Cone";
    p.Bodies.Add(cone);
    
  4. Boolean Operations

    • Create the intersection between the box and the cone

      Body[] intersection = box.Intersect(cone);
      foreach (Body b in intersection)
      {
          b.Name = "Intersection Body";
          p.Bodies.Add(b);
      }
      
    • Cut the cone with the box

      Body[] cut = cone.Cut2(box);
      foreach (Body b in cut)
      {
          b.Name = "Cut Body";
          p.Bodies.Add(b);
      }
      
    • Join the box and the cone

      Body[] union = box.Join(cone);
      foreach (Body b in union)
      {
          b.Name = "Join Body";
          p.Bodies.Add(b);
      }
      

Example

This example provides information on using boolean operations in RobotStudio.

public void BodyBooleanOperations()
{
    NewStation();
    Project.UndoContext.BeginUndoStep("BodyBooleanOperations");
    try
    {
        Station station = Station.ActiveStation;

        // Create a part to contain the bodies.
        Part p = new Part();
        p.Name = "My_Part";
        station.GraphicComponents.Add(p);

        // Create a solid box.
        Matrix4 matrix_origo = new Matrix4(new Vector3(Axis.X), 0.0);
        Vector3 size = new Vector3(0.5, 0.5, 0.5);
        Body box = Body.CreateSolidBox(matrix_origo, size);
        box.Name = "Box";
        p.Bodies.Add(box);

        // Create a cone.
        Body cone = Body.CreateSolidCone(matrix_origo, 1.0, 1.0);
        cone.Name = "Cone";
        p.Bodies.Add(cone);

        // Create the intersection between the box and the cone.
        Body[] intersection = box.Intersect(cone);
        foreach (Body b in intersection)
        {
            b.Name = "Intersection Body";
            p.Bodies.Add(b);
        }

        //Cut the cone with the box
        Body[] cut = cone.Cut2(box);
        foreach (Body b in cut)
        {
            b.Name = "Cut Body";
            p.Bodies.Add(b);
        }

        // Join the box and the cone.
        Body[] union = box.Join(cone);
        foreach (Body b in union)
        {
            b.Name = "Join Body";
            p.Bodies.Add(b);
        }
    }
    catch
    {
        Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
        throw;
    }
    finally
    {
        Project.UndoContext.EndUndoStep();
    }
}

Required Namespaces

ABB.Robotics.RobotStudio

ABB.Robotics.RobotStudio.Stations

See Also

  • Creating Solids
  • Creating Surfaces
In this article
Back to top Copyright © 2024 ABB