Hello together,
I want to pick an edge on a part in Robotstudio, but I can’t find a direct way to do it. Is it possible to display and select the edge?
With “GraphicPicker” I can set selection to “Face” and snap to “edge”. Then I get the face and Pickposition back, see VB.NET code below. But how can I retrieve the edge that was clicked?
First I set SelectionMode and SnapMode, then add the handler for subPickEdge
oclass.SetSelectionMode(SelectionModes.Surface)
oclass.SetSnapMode(SnapMode.Edge)
AddHandler GraphicPicker.GraphicPick, AddressOf subPickEdge
The Sub for Picking is defined as
Shared Sub subPickEdge(ByVal sender As Object, ByVal e As GraphicPickEventArgs)
Try
If Not (e.PickedObject Is Nothing) Then
'picked object is a face, even if i pick an edge
Dim oFace As Face
oFace = e.PickedObject
'Pickposition
Dim oPos As Vector3
oPos = e.PickedPosition
'calculate the Pickposition into 'face coordinats'
Dim oLSBody As Body
oLSBody = oFace.Body
Dim mLSTFFace As Matrix4 = oLSBody.Transform.GlobalMatrix
Dim mLSTFFaceINV As Matrix4 = oLSBody.Transform.GlobalMatrix
mLSTFFaceINV.InvertRigid()
Dim oPosinFace As Vector3
oPosinFace = mLSTFFaceINV.MultiplyPoint(oPos)
Debug.Print(oPosinFace.ToString & "->" & oPos.ToString)
'access the coedges of the face
Dim oPostemp As Vector3
For Each oLoop In oFace.Loops
For Each oCoedge In oLoop.Coedges
oPostemp = mLSTFFace.MultiplyPoint(oCoedge.StartVertex.Position)
'Print StartVertex of Coedge in both WCS and PartCS
Debug.Print(oCoedge.StartVertex.Position.ToString & "->" & oPostemp.ToString)
Next
Next
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Does anyone have any advice or a solution to my problem?
Best Regards
Wolfgang