RobotStudio event

Wire.GetLengthAtPoint returns wrong value

RS 5.12

The uploaded .zip file includes a Pack&Go station and a VB Add-in.
webwiz/40/WireTest4.zip

The API help for 'Wire.GetLengthAtPoint' states:
"Returns the curve length from the start point of the wire to
the supplied point on the wire."

This is my code:[CODE].
.
dblMyWireLen = bdyMyWire.Shells(0).Wires(0).Length    'get wire length
.
.
'Display data when selection changed
Public Sub SelectionChanged(ByVal sender As Object, ByVal e As GraphicPickEventArgs)
    If e.PickedObject IsNot Nothing Then
        Dim dblLengthAtPoint As Double                  'distance along wire of selected point
        dblLengthAtPoint = bdyMyWire.Shells.Item(0).Wires.Item(0).GetLengthAtPoint(e.PickedPosition)
        Logger.AddMessage(New LogMessage("Selected object type = " & e.PickedObject.TypeDisplayName & _
               ";   dblLengthAtPoint = " & dblLengthAtPoint & ";   Wire Length = " & dblMyWireLen))
    End If
End Sub[/CODE]
When I click at different points on a wire 'GetLengthAtPoint(e.PickedPosition)' returns a constant value which is equal to the value returned by Wire.Length.

Is this a bug or have I made an error?

Thanks,

Kevin

Comments

  • Bump:

    I would be grateful if someone would confirm that this is a bug in RS or point out my error.

    Thanks,

    Kevin


  • Hi Kevin,

    GetLengthAtPoint expects a local coordinate (relative to the containing Part) while GraphicPickEventArgs always contains a global coordinate.
    Sample C# code:
    [code]        static void GraphicPicker_GraphicPick(object sender, GraphicPickEventArgs e)
            {
                Wire wire = e.PickedObject as Wire;
                if (wire != null)
                {
                    Matrix4 mat = ((Part)wire.Body.Parent).Transform.GlobalMatrix;
                    mat.InvertRigid();
                    Vector3 local = mat.MultiplyPoint(e.PickedPosition);
                    Logger.AddMessage(new LogMessage(wire.GetLengthAtPoint(local).ToString()));
                }
            }[/code]
    regards,
    Johannes

    Johannes Weiman2009-12-18 14:20:29
    Johannes Weiman
    Software Engineer
    ABB Robotics
  • Thanks for the explanation and example, Johannes.

    Regards,

    Kevin