4 Replies Latest reply on Aug 16, 2018 4:21 AM by Sergio Monti

    How to rotate robot joints synchronously ?

    Chiao Yang Chang

      I can use CreateTransformRotateAxis function to rotate a joint of the robot.(see the codes and video below)

      However,it seems that the function just only rotate one component separately.

      I want to rotate all joints at the same time.

      How to rotate robot joints synchronously like the example in YouTube? (synchronous motion)




      Private Sub MySub1()

             Dim swModel As ModelDoc2

             Dim swModelDocExt As ModelDocExtension

             Dim swAssy As AssemblyDoc

             Dim swDragOp As DragOperator

             Dim swSelMgr As SelectionMgr

             Dim swXform As MathTransform

             Dim swMathUtil As MathUtility

             Dim nPts(2) As Double

             Dim bRet As Boolean       
             swModel = swApp.ActiveDoc
             swAssy = swModel
             swDragOp = swAssy.GetDragOperator
             swSelMgr = swModel.SelectionManager
             swMathUtil = swApp.GetMathUtility
             swModelDocExt = swModel.Extension


             Dim strRefPlaneName As String

             Dim swRefPlane As RefPlane

             Dim swRefPlaneTransform As MathTransform


             'Get Reference Plane      
             strRefPlaneName = swFeature(0).Name
             swRefPlane = swFeature(0).GetSpecificFeature2
             swRefPlaneTransform = swRefPlane.Transform


             '===[Origin Point]===

             Dim aPointData(2) As Double      
            aPointData(0) = 0#
            aPointData(1) = 0#
            aPointData(2) = 0#

             ' Turn into a Variant

             Dim vPointData As Object = aPointData

             ' Create a math point

             Dim swOriginPoint As MathPoint      
             swOriginPoint = swMathUtil.CreatePoint(vPointData)

             ' Transform the reference plane origin from its canonical position to its actual position

             Dim swOriginPointOnRefPlane As MathPoint      
             swOriginPointOnRefPlane =swOriginPoint.MultiplyTransform(swRefPlaneTransform)

             ' Get point data      
             vPointData = swOriginPointOnRefPlane.ArrayData



             Dim aVectorData(2) As Double      
             aVectorData(0) = 0#
             aVectorData(1) = 0#
             aVectorData(2) = 1.0#


             Dim vVectorData As Object      
             vVectorData = aVectorData

             Dim swNormalVector As MathVector     
             swNormalVector = swMathUtil.CreateVector(vVectorData)

             Dim swNormalVectorRefPlane As MathVector      
             swNormalVectorRefPlane =swNormalVector.MultiplyTransform(swRefPlaneTransform)

             vVectorData = swNormalVectorRefPlane.ArrayData       
             swDragOp.DynamicClearanceEnabled =

             swDragOp.TransformType = 1

             swDragOp.DragMode = 1

             bRet = swDragOp.AddComponent(swComp(0),
             swXform = swMathUtil.CreateTransformRotateAxis(swOriginPointOnRefPlane, swNormalVectorRefPlane, 1 * RadPerDeg)

      bRet = swDragOp.BeginDrag

             Dim nNow As Single

             For i = 0 To 44

              bRet = swDragOp.DragAsUI(swXform)  
              nNow =Microsoft.VisualBasic.Timer

                  While Microsoft.VisualBasic.Timer < nNow +0.01


                  End While

             Next i      
      bRet = swDragOp.EndDrag


      End Sub