Wire.GetLengthAtPoint returns wrong value
Kevin
✭✭
in RobotStudio
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
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
0
Comments
-
Bump:
I would be grateful if someone would confirm that this is a bug in RS or point out my error.
Thanks,
Kevin
0 -
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:29Johannes Weiman
Software Engineer
ABB Robotics0 -
Thanks for the explanation and example, Johannes.
Regards,
Kevin
0
Categories
- All Categories
- 5.5K RobotStudio
- 396 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 249 ScreenMaker
- 2.7K Robot Controller
- 310 IRC5
- 59 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 786 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 5 Job listings