RobotStudio event

How can i search all of my Teach Robtarget with PC SDK 5.15

Hallo everyone!

i have a TeachProc look like this.

All teachpositions have no Name. And I do not know how many teachpositions are there.

My question is:

How can i get all of the Teachpositions with PC SDK 5.15.

How can i know how many there are. (a int   number)

TKS!

Zheng from Germany.

PROC MyTeachProc() MoveL [[-184.38,60.22,-267],[0.00343136,2.18549E-05,-9.15364E-05,-0.999994],[0,0,-3,0],[9E+09,9E+09,9E+09,9E+09,9E+09,-927.16]],v1000,z50,tMess\WObj:=Wobj_Teachen; MoveL [[-6.69,60.27,-267],[0.00343736,2.63988E-05,-0.000104671,-0.999994],[0,0,-3,0],[9E+09,9E+09,9E+09,9E+09,9E+09,-927.16]],v1000,z50,tMess\WObj:=Wobj_Teachen; MoveL [[170.74,60.30,-267],[0.00343401,3.25996E-05,-0.000123344,-0.999994],[0,0,-3,0],[9E+09,9E+09,9E+09,9E+09,9E+09,-927.16]],v1000,z50,tMess\WObj:=Wobj_Teachen; MoveL [[209.95,94.40,-277],[0.00344324,4.30399E-05,-0.000149885,-0.999994],[0,0,-3,0],[9E+09,9E+09,9E+09,9E+09,9E+09,-927.16]],v1000,z50,tMess\WObj:=Wobj_Teachen; MoveL [[-8.06,94.48,-277],[0.00344843,6.25896E-05,-0.000176107,-0.999994],[0,0,-3,0],[9E+09,9E+09,9E+09,9E+09,9E+09,-927.16]],v1000,z50,tMess\WObj:=Wobj_Teachen; MoveL [[-224.31,94.46,-277],[0.00345582,8.38642E-05,-0.000203436,-0.999994],[0,0,-3,0],[9E+09,9E+09,9E+09,9E+09,9E+09,-927.16]],v1000,z50,tMess\WObj:=Wobj_Teachen; MoveL [[-218.07,321.77,-55.22],[0.00342084,9.28496E-05,-0.000242095,-0.999994],[0,0,-3,0],[9E+09,9E+09,9E+09,9E+09,9E+09,-927.16]],v1000,z50,tMess\WObj:=Wobj_Teachen; MoveL [[-5.90,321.82,-53.68],[0.00342156,9.53777E-05,-0.000253821,-0.999994],[0,0,-3,0],[9E+09,9E+09,9E+09,9E+09,9E+09,-927.16]],v1000,z50,tMess\WObj:=Wobj_Teachen; MoveL [[212.26,322.11,-67.05],[0.00342027,9.87941E-05,-0.00027401,-0.999994],[0,0,-3,0],[9E+09,9E+09,9E+09,9E+09,9E+09,-927.16]],v1000,z50,tMess\WObj:=Wobj_Teachen; MoveL [[137.44,404.72,-44.50],[0.00337016,0.000284998,-0.000694469,-0.999994],[0,0,-3,0],[9E+09,9E+09,9E+09,9E+09,9E+09,-927.16]],v1000,z50,tMess\WObj:=Wobj_Teachen; MoveL [[1.09,404.75,-35.89],[0.00336047,0.000283579,-0.000702743,-0.999994],[0,0,-3,0],[9E+09,9E+09,9E+09,9E+09,9E+09,-927.16]],v1000,z50,tMess\WObj:=Wobj_Teachen; MoveL [[-147.09,408.32,-40.60],[0.00335823,0.000281222,-0.000706991,-0.999994],[0,0,-3,0],[9E+09,9E+09,9E+09,9E+09,9E+09,-927.16]],v1000,z50,tMess\WObj:=Wobj_Teachen; MoveL [[-225.49,468.48,-124.11],[0.00336177,0.000279784,-0.000713442,-0.999994],[0,0,-3,0],[9E+09,9E+09,9E+09,9E+09,9E+09,-927.16]],v1000,z50,tMess\WObj:=Wobj_Teachen; MoveL [[-4.78,488.27,-101.83],[0.017577,0.0779157,-0.06025,-0.994983],[0,0,-3,0],[9E+09,9E+09,9E+09,9E+09,9E+09,-927.16]],v1000,z50,tMess\WObj:=Wobj_Teachen; MoveL [[206.07,470.90,-134.36],[0.0175729,0.0779154,-0.0602675,-0.994982],[0,0,-3,0],[9E+09,9E+09,9E+09,9E+09,9E+09,-927.16]],v1000,z50,tMess\WObj:=Wobj_Teachen; MoveL [[205.03,588.83,-228.24],[0.0175801,0.0779118,-0.0602734,-0.994981],[0,0,-3,0],[9E+09,9E+09,9E+09,9E+09,9E+09,-927.16]],v1000,z50,tMess\WObj:=Wobj_Teachen; MoveL [[-7.26,605.40,-189.54],[0.017582,0.0779074,-0.0602744,-0.994982],[0,0,-3,0],[9E+09,9E+09,9E+09,9E+09,9E+09,-927.16]],v1000,z50,tMess\WObj:=Wobj_Teachen; MoveL [[-228.74,585.88,-218.67],[0.0175725,0.0779053,-0.0602814,-0.994982],[0,0,-3,0],[9E+09,9E+09,9E+09,9E+09,9E+09,-927.16]],v1000,z50,tMess\WObj:=Wobj_Teachen; MoveL [[-129.00,685.60,-261.55],[0.0175709,0.0778973,-0.0602878,-0.994982],[0,0,-3,0],[9E+09,9E+09,9E+09,9E+09,9E+09,-927.16]],v1000,z50,tMess\WObj:=Wobj_Teachen; MoveL [[-14.16,694.29,-258.12],[0.0175869,0.0779009,-0.0603,-0.994981],[0,0,-3,0],[9E+09,9E+09,9E+09,9E+09,9E+09,-927.16]],v1000,z50,tMess\WObj:=Wobj_Teachen; MoveL [[100.14,687.10,-269.22],[0.0175839,0.0778977,-0.0603063,-0.99498],[0,0,-3,0],[9E+09,9E+09,9E+09,9E+09,9E+09,-927.16]],v1000,z50,tMess\WObj:=Wobj_Teachen; ENDPROC


Comments

  • <font face="Arial, Verdana"><span style="font-size: 10pt; line-height: normal;">Hi, you should to use a function for get all the target be use.</span></font><div><font face="Arial, Verdana"><span style="font-size: 13.3333330154419px; line-height: normal;">General Declaration :     Dim RobTab As New HashSet(Of String)  'HashSet use for not duplicate position</span></font></div><div><span style="line-height: 1.7em;">Function to find target : </span></div><div><div>    Private Sub RobTargetUtil()</div></div><div><div><div><font face="Arial, Verdana"><span style="font-size: 13.3333330154419px; line-height: normal;"><span class="Apple-tab-span" style="white-space:pre"> </span> Dim station As Station = TryCast(Project.ActiveProject, Station)</span></font></div><div><font face="Arial, Verdana"><span style="font-size: 13.3333330154419px; line-height: normal;">        Dim actTask As RsTask = Nothing</span></font></div><div><font face="Arial, Verdana"><span style="font-size: 13.3333330154419px; line-height: normal;">        Dim instructionsmouvement As List(Of RsPathProcedure) = station.ActiveTask.PathProcedures.ToList</span></font></div><div><font face="Arial, Verdana"><span style="font-size: 13.3333330154419px; line-height: normal;">        RobTab.Clear()</span></font></div><div><font face="Arial, Verdana"><span style="font-size: 13.3333330154419px; line-height: normal;">            Dim counter As Integer = 0</span></font></div><div><font face="Arial, Verdana"><span style="font-size: 13.3333330154419px; line-height: normal;">            If instructionsmouvement IsNot Nothing Then</span></font></div><div><font face="Arial, Verdana"><span style="font-size: 13.3333330154419px; line-height: normal;">                For Each Paths As RsPathProcedure In instructionsmouvement</span></font></div><div><span style="font-size: 13.3333330154419px; line-height: normal; font-family: Arial, Verdana;">                        Dim procedure1 As RsPathProcedure = station.ActiveTask.FindPathProcedureFromModuleScope(Paths.ToString, "module1")</span><br></div><div><font face="Arial, Verdana"><span style="font-size: 13.3333330154419px; line-height: normal;">                        Dim listRs1 As List(Of RsInstruction) = procedure1.Instructions.ToList</span></font></div><div><font face="Arial, Verdana"><span style="font-size: 13.3333330154419px; line-height: normal;">                        For Each move As RsInstruction In listRs1</span></font></div><div><font face="Arial, Verdana"><span style="font-size: 13.3333330154419px; line-height: normal;">                                RobTab.Add(move.InstructionArguments.Item("ToPoint").Value)</span></font></div><div><font face="Arial, Verdana"><span style="font-size: 13.3333330154419px; line-height: normal;">                        Next</span></font></div><div><font face="Arial, Verdana"><span style="font-size: 13.3333330154419px; line-height: normal;">                    End If</span></font></div><div><font face="Arial, Verdana"><span style="font-size: 13.3333330154419px; line-height: normal;">                Next</span></font></div><div><font face="Arial, Verdana"><span style="font-size: 13.3333330154419px; line-height: normal;">            End If</span></font></div><div><font face="Arial, Verdana"><span style="font-size: 13.3333330154419px; line-height: normal;"> End Sub</span></font></div></div><div><font face="Arial, Verdana"><span style="font-size: 13.3333330154419px; line-height: normal;"><br></span></font></div><div><span style="font-family: Arial, Verdana; font-size: 13.3333330154419px; line-height: normal;">Now, you should save the position for each target be use with  the name</span></div><div><div><span style="font-family: Arial, Verdana; font-size: 13.3333330154419px; line-height: normal;"><br></span></div><div><div><span style="font-family: Arial, Verdana; font-size: 13.3333330154419px; line-height: normal;"> <span class="Apple-tab-span" style="white-space:pre"> </span>Dim station As Station = TryCast(Project.ActiveProject, Station)</span></div><div><span style="font-family: Arial, Verdana; font-size: 13.3333330154419px; line-height: normal;">                    Dim actTask As RsTask = Nothing</span></div><div><span style="font-family: Arial, Verdana; font-size: 13.3333330154419px; line-height: normal;">                RobTargetUtil()</span></div><div><span style="font-family: Arial, Verdana; font-size: 13.3333330154419px; line-height: normal;">                    Dim instructionsmouvement As List(Of RsPathProcedure) = station.ActiveTask.PathProcedures.ToList</span><br></div><div><span style="font-family: Arial, Verdana; font-size: 13.3333330154419px; line-height: normal;">                    Dim listtarget As RsTargetCollection = station.ActiveTask.Targets</span></div></div><div><span style="font-family: Arial, Verdana; font-size: 13.3333330154419px; line-height: normal;"><br></span></div><div><span style="font-family: Arial, Verdana; font-size: 13.3333330154419px; line-height: normal;">For Each rob As String In RobTab</span></div><div><span style="font-family: Arial, Verdana; font-size: 13.3333330154419px; line-height: normal;">                        Dim robok As Boolean = False</span></div><div><span style="font-family: Arial, Verdana; font-size: 13.3333330154419px; line-height: normal;">                        For Each target As RsTarget In listtarget</span></div><div><span style="font-family: Arial, Verdana; font-size: 13.3333330154419px; line-height: normal;">                            If target.Name = rob Then</span></div><div><span style="font-family: Arial, Verdana; font-size: 13.3333330154419px; line-height: normal;">                                Dim X As Double = target.RobTarget.Frame.X * 1000</span></div><div><span style="font-family: Arial, Verdana; font-size: 13.3333330154419px; line-height: normal;">                                Dim Y As Double = target.RobTarget.Frame.Y * 1000</span></div><div><span style="font-family: Arial, Verdana; font-size: 13.3333330154419px; line-height: normal;">                                Dim Z As Double = target.RobTarget.Frame.Z * 1000</span></div><div><span style="font-family: Arial, Verdana; font-size: 13.3333330154419px; line-height: normal;">                                sw.WriteLine("  PERS robtarget " & target.RobTarget.Name & ":=[[" & Replace(X.ToString, ",", ".") & "," & Replace(Y.ToString, ",", ".") & "," & Replace(Z.ToString, ",", ".") & "],[" & Replace(target.RobTarget.Frame.GlobalMatrix.Quaternion.q1.ToString, ",", ".") & "," & Replace(target.RobTarget.Frame.GlobalMatrix.Quaternion.q2.ToString, ",", ".") & "," & Replace(target.RobTarget.Frame.GlobalMatrix.Quaternion.q3.ToString, ",", ".") & "," & Replace(target.RobTarget.Frame.GlobalMatrix.Quaternion.q4.ToString, ",", ".") & "],[" & target.RobTarget.ConfigurationData.Cf1.ToString & "," & target.RobTarget.ConfigurationData.Cf4.ToString & "," & target.RobTarget.ConfigurationData.Cf6.ToString & "," & target.RobTarget.ConfigurationData.Cfx.ToString & "],[" & Replace(target.RobTarget.GetExternalAxes(False).Eax_a, ",", ".") & "," & Replace(target.RobTarget.GetExternalAxes(False).Eax_b, ",", ".") & "," & Replace(target.RobTarget.GetExternalAxes(False).Eax_c, ",", ".") & "," & Replace(target.RobTarget.GetExternalAxes(False).Eax_d, ",", ".") & "," & Replace(target.RobTarget.GetExternalAxes(False).Eax_e, ",", ".") & "," & Replace(target.RobTarget.GetExternalAxes(False).Eax_f, ",", ".") & "]];")</span></div><div><span style="font-family: Arial, Verdana; font-size: 13.3333330154419px; line-height: normal;">                                robok = True</span></div><div><span style="font-family: Arial, Verdana; font-size: 13.3333330154419px; line-height: normal;">                            End If</span></div><div><span style="font-family: Arial, Verdana; font-size: 13.3333330154419px; line-height: normal;">                        Next</span></div></div><div><span style="font-family: Arial, Verdana; font-size: 13.3333330154419px; line-height: normal;"><br></span></div><div><span style="font-family: Arial, Verdana; font-size: 13.3333330154419px; line-height: normal;">Best Regards</span></div><div style="font-family: Arial, Verdana; font-size: 10pt; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"><br></div></div>