AnsweredAssumed Answered

How to Translate a component

Question asked by Nouha Ba on Dec 5, 2018
Latest reply on Dec 8, 2018 by Nouha Ba

Hello,

i'm trying to translate a component in solidworks using vb.net with this algorithm :

#code

       CompName = "part"

        swComp = swAssy.GetComponentByName(CompName)

        swDragOp = swApp.ActiveDoc.GetDragOperator

        swSelMgr = swModel.SelectionManager

       swMathUtil = swApp.GetMathUtility

  bRet = swDragOp.AddComponent(swComp, False)

        swDragOp.CollisionDetectionEnabled = False

        swDragOp.DynamicClearanceEnabled = False

        swDragOp.TransformType = 0

        swDragOp.DragMode = 1

        bRet = swDragOp.BeginDrag

        Dim maxsteps As Integer

        maxsteps = 50    ' i want to move it 50 mm

        Dim x(1000) As Double

        Dim arr(15) As Double

        Dim vXform As Object

        For i = 1 To maxsteps

            arr(0) = 1.0# : arr(1) = 0# : arr(2) = 0#

            arr(3) = 0# : arr(4) = 1.0# : arr(5) = 0#

            arr(6) = 0# : arr(7) = 0# : arr(8) = 1.0#

            arr(9) = x(i)

            arr(10) = 0#

            arr(11) = 0#

            arr(12) = 1.0#

            arr(13) = 0# : arr(14) = 0# : arr(15) = 0#

            vXform = arr

            swMathXform = swMathUtil.CreateTransform((vXform))

            Debug.Print("x = " & i)

        Next

        bRet = swDragOp.EndDrag

 

but, i don't get a result.

Outcomes