Show / Hide Table of Contents

Curve Manipulations

This example provides information on joining curves, projecting a line on a surface, splitting wires, and intersect and trimming curves.

Run the Addin and go to the Modelling browser. The easiest way to see the different bodies is to make them visible one at a time.

Use this procedure to manipulate the curves:

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

  2. Join the curves

    • Create two lines (wires)

    • Create a Wire array with the wires that should be joined

  3. Project wire on the surface of the cylinder along the X-axis

    • CreateSolidCylinder(Matrix4, double, double)

    • Create a wire array containing the first wire, and a body array containing the cylinder.

    • Project Curve along X-axis

  4. Create a semicircle shaped wire

    • Create a circle

    • Create a line to intersect the circle with.

    • Join the circle and the line

    • Get the wire of the union

    • Get the section to trim

    • Trim points to array

Solution

  1. Create Part Object to contain the Bodies and Add it to the station

    Part p = new Part();
    p.Name = "My_Curve_Manipulations";
    station.GraphicComponents.Add(p);
    
  2. Join the curves

    • Create two lines (wires)

      Body wire1 = Body.CreateLine(new Vector3(0.0, 0.0, 0.0), new Vector3(0.5, 0.5, 0.5));
      wire1.Name = "Wire1";
      p.Bodies.Add(wire1);
      Body wire2 = Body.CreateLine(new Vector3(0.0, 0.0, 0.0), new Vector3(-0.5, 0.5, 0.5));
      wire2.Name = "Wire2";
      p.Bodies.Add(wire2);
      
    • Create a wire array with the wires that should be joined

      Wire[] wires = new Wire[2] { wire1.Shells[0].Wires[0], wire2.Shells[0].Wires[0] };
      Body[] wireUnion = Body.JoinCurves(wires);
      foreach (Body b in wireUnion)
      {
          b.Name = "Wire Array";
          p.Bodies.Add(b);
      }
      
  3. Project wire on the surface of the cylinder along the X-axis

    • Create solid cylinder

      Matrix4 origin = new Matrix4(new Vector3(Axis.X), 0.0);
      Body cylinder = Body.CreateSolidCylinder(origin, 0.2, 1);
      cylinder.Name = "Cylinder";
      p.Bodies.Add(cylinder);
      
    • Create a wire array containing the first wire, and a body array containing the cylinder.

      Wire[] wires2 = new Wire[1] { wire1.Shells[0].Wires[0] };
      Body[] bodies = new Body[1] { cylinder };
      
    • Project Curve along X-axis

      Body[] projection = Body.ProjectCurve(wires2, bodies, Vector3.XVector);
      foreach (Body b in projection)
      {
          b.Name = "Wire1 projected on the cylinders surface along x-axis";
          p.Bodies.Add(b);
      }
      
  4. Create a semicircle shaped wire

    • Create a circle

      Body circle = Body.CreateCircle(new Matrix4(Vector3.XVector, 0.0), 0.5);
      circle.Name = "Circle";
      p.Bodies.Add(circle);
      
    • Create a line to intersect the circle with.

      Body line = Body.CreateLine(new Vector3(0.5, 0.0, 0.0), new Vector3(-0.5, 0.0, 0.0));
      line.Name = "Line";
      p.Bodies.Add(line);
      
    • Join the circle and the line

      Wire[] ws = new Wire[2] { circle.Shells[0].Wires[0], line.Shells[0].Wires[0] };
      Body[] union = Body.JoinCurves(ws);
      
    • Get the wire of the union

      Wire unionWire = union[0].Shells[0].Wires[0];
      
    • Get the section to trim

      Vector3 sectionSelectionPoint = new Vector3(0.0, -0.5, 0.0);
      Vector3 firstTrimPoint = new Vector3(-0.5, 0.0, 0.0);
      Vector3 secondTrimPoint = new Vector3(0.5, 0.0, 0.0);
      
    • Trim points to array

      Vector3[] testPoints = new Vector3[2] { firstTrimPoint, secondTrimPoint };
      CurveSection trimSection = unionWire.GetSection(sectionSelectionPoint, testPoints);
      Body[] trimmedCircle = Body.TrimCurve(unionWire, trimSection);
      foreach (Body b in trimmedCircle)
      {
          b.Name = "Semicircle from cirle and line";
          p.Bodies.Add(b);
      }
      

Example

This example provides information on joining curves, projecting a line on a surface, splitting wires, and intersect and trimming curves.

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

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

        // Joined curves.
        // Create two lines (wires).
        Body wire1 = Body.CreateLine(new Vector3(0.0, 0.0, 0.0), new Vector3(0.5, 0.5, 0.5));
        wire1.Name = "Wire1";
        p.Bodies.Add(wire1);
        Body wire2 = Body.CreateLine(new Vector3(0.0, 0.0, 0.0), new Vector3(-0.5, 0.5, 0.5));
        wire2.Name = "Wire2";
        p.Bodies.Add(wire2);

        // Create a wire array with the wires that should be joined.
        Wire[] wires = new Wire[2] { wire1.Shells[0].Wires[0], wire2.Shells[0].Wires[0] };
        Body[] wireUnion = Body.JoinCurves(wires);
        foreach (Body b in wireUnion)
        {
            b.Name = "Wire Array";
            p.Bodies.Add(b);
        }

        // Create solid cylinder.
        Matrix4 origin = new Matrix4(new Vector3(Axis.X), 0.0);
        Body cylinder = Body.CreateSolidCylinder(origin, 0.2, 1);
        cylinder.Name = "Cylinder";
        p.Bodies.Add(cylinder);

        // Create a wire array containing the first wire, 
        // and a body array containing the cylinder.
        Wire[] wires2 = new Wire[1] { wire1.Shells[0].Wires[0] };
        Body[] bodies = new Body[1] { cylinder };

        // Project wire1 on the surface of the cylinder along the X-axis.
        Body[] projection = Body.ProjectCurve(wires2, bodies, Vector3.XVector);
        foreach (Body b in projection)
        {
            b.Name = "Wire1 projected on the cylinders surface along x-axis";
            p.Bodies.Add(b);
        }

        // Split wire1 in half.                            
        Body[] splitCurves = Body.SplitCurve(wire1.Shells[0].Wires[0], new Vector3(0.25, 0.25, 0.25));
        foreach (Body b in splitCurves)
        {
            b.Name = "Wire1 split in half";
            p.Bodies.Add(b);
        }

        // Create a semicircle shaped wire.
        // Create a circle.
        Body circle = Body.CreateCircle(new Matrix4(Vector3.XVector, 0.0), 0.5);
        circle.Name = "Circle";
        p.Bodies.Add(circle);

        // Create a line to intersect the circle with.
        Body line = Body.CreateLine(new Vector3(0.5, 0.0, 0.0), new Vector3(-0.5, 0.0, 0.0));
        line.Name = "Line";
        p.Bodies.Add(line);

        // Join the circle and the line.
        Wire[] ws = new Wire[2] { circle.Shells[0].Wires[0], line.Shells[0].Wires[0] };
        Body[] union = Body.JoinCurves(ws);

        // Get the wire of the union.
        Wire unionWire = union[0].Shells[0].Wires[0];

        // Get the section to trim.
        Vector3 sectionSelectionPoint = new Vector3(0.0, -0.5, 0.0);
        Vector3 firstTrimPoint = new Vector3(-0.5, 0.0, 0.0);
        Vector3 secondTrimPoint = new Vector3(0.5, 0.0, 0.0);

        // Trim points to array.
        Vector3[] testPoints = new Vector3[2] { firstTrimPoint, secondTrimPoint };
        CurveSection trimSection = unionWire.GetSection(sectionSelectionPoint, testPoints);
        Body[] trimmedCircle = Body.TrimCurve(unionWire, trimSection);
        foreach (Body b in trimmedCircle)
        {
            b.Name = "Semicircle from cirle and line";
            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
  • Extrude
In this article
Back to top Copyright © 2024 ABB