Interface IHasGeometry
Represents a geometric entity or primitive.
Namespace: ABB.Robotics.RobotStudio.Stations
Assembly: ABB.Robotics.RobotStudio.Stations.dll
Syntax
public interface IHasGeometry
Methods
FindClosestVertex(Vector3)
Finds the closest vertex, of the object, to the point.
Declaration
Vertex FindClosestVertex(Vector3 testPoint)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | testPoint | The point. |
Returns
Type | Description |
---|---|
Vertex | The vertex. |
Examples
Find closest Vertex.
Project.UndoContext.BeginUndoStep("BodyMethods");
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 two points.
Vector3 point1 = new Vector3(0.1, 0.1, 0.1);
Vector3 point2 = new Vector3(0.6, 0.6, 0.6);
// Test if the points are inside the box.
Logger.AddMessage(new LogMessage("Point one " + point1.ToString() + " is inside the box: " + box.IsPointInside(point1).ToString()));
Logger.AddMessage(new LogMessage("Point two " + point2.ToString() + " is inside the box: " + box.IsPointInside(point2).ToString()));
// Find the vertex closest to point2.
Vertex closestVert = box.FindClosestVertex(point2);
Logger.AddMessage(new LogMessage("The closest vertex to point2 is : (" + closestVert.Position.x.ToString() +
", " + closestVert.Position.y.ToString() +
", " + closestVert.Position.z.ToString() + ")"));
// Copy the box.
Body boxcopy = (Body)box.Copy();
boxcopy.Name = "Copy of " + box.Name;
p.Bodies.Add(boxcopy);
// Remove the original box body.
p.Bodies.Remove(box);
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}