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, a cut of the box from the cone, and a join of 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.
Shows the intersection operation on Box and Cone.
Shows the cut operation on Box and Cone.
Shows the join operation on Box and Cone.
Solution
Create a Part object to contain the bodies and add it to the Station
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);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); }Use the method Join(Body) to 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.
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.Stations