Hide Table of Contents

Create Triad Manipulator Example (VBA)

This example shows how to create a triad manipulator.

Module

'----------------------------------------------------

'

' Preconditions:

'           (1) Model document is open.

'           (2) Face is selected.

'

' Postconditions: Triad manipulator is created.

'

'-----------------------------------------------------

Option Explicit

Public Enum swManipulatorType_e

    swTriadManipulator = 0

End Enum

Public Enum swManipulatorRepresentation_e

    swManipulatorRepresentationNone = 0

    swManipulatorRepresentationSquare = sManipulatorRepresentationNone + 1

    swManipulatorRepresentationCircle = sManipulatorRepresentationSquare + 1

    swManipulatorRepresentationDiamond = sManipulatorRepresentationCircle + 1

    swManipulatorRepresentationTriangle = sManipulatorRepresentationDiamond + 1

    swManipulatorRepresentationArrow = sManipulatorRepresentationTriangle + 1

    swManipulatorRepresentationTextBox = sManipulatorRepresentationArrow + 1

    swManipulatorRepresentationRotationHandle = swManipulatorRepresentationTextBox + 1

    swManipulatorRepresentationPanHandle = swManipulatorRepresentationRotationHandle + 1

    swManipulatorRepresentationScaleHandle = swManipulatorRepresentationPanHandle + 1

    swManipulatorRepresentationSurfTopol = swManipulatorRepresentationScaleHandle + 1

    swManipulatorRepresentationWireTopol = swManipulatorRepresentationSurfTopol + 1

    swManipulatorRepresentationMiscTopol = swManipulatorRepresentationWireTopol + 1

    swManipulatorRepresentationBitmap = swManipulatorRepresentationMiscTopol + 1

    swManipulatorRepresentationShadow = swManipulatorRepresentationBitmap + 1

    swManipulatorRepresentationEmpty = swManipulatorRepresentationShadow + 1

End Enum

Public Enum swTriadManipulatorDoNotShow_e

    swTriadManipulatorShowAll = 0

    swTriadManipulatorDoNotShowOrigin = &H1

    swTriadManipulatorDoNotShowXAxis = &H2

    swTriadManipulatorDoNotShowYAxis = &H4

    swTriadManipulatorDoNotShowZAxis = &H8

    swTriadManipulatorDoNotShowXYPlane = &H10

    swTriadManipulatorDoNotShowYZPlane = &H20

    swTriadManipulatorDoNotShowZXPlane = &H40

End Enum

Public Enum swTriadManipulatorControlPoints_e

    swTriadManipulatorOrigin = 0

    swTriadManipulatorXAxis = 1

    swTriadManipulatorYAxis = 2

    swTriadManipulatorZAxis = 3

    swTriadManipulatorXYPlane = 4

    swTriadManipulatorYZPlane = 5

    swTriadManipulatorZXPlane = 6

End Enum

    Dim swManip                     As SldWorks.Manipulator

    Public swTriad                  As SldWorks.TriadManipulator

    Dim swDragHdlr                  As swDragManipHdlr

    Public swFace                   As SldWorks.face2

    

Sub main()

    Dim swApp                       As SldWorks.SldWorks

    Dim swMathUtil                  As SldWorks.MathUtility

    Dim swModel                     As SldWorks.ModelDoc2

    Dim swModViewMgr                As SldWorks.ModelViewManager

    Dim swSelMgr                    As SldWorks.SelectionMgr

    Dim vPickPt                     As Variant

    Dim swPickPt                    As SldWorks.MathPoint

    

    Set swDragHdlr = New swDragManipHdlr

    

    Set swApp = Application.SldWorks

    Set swMathUtil = swApp.GetMathUtility

    Set swModel = swApp.ActiveDoc

    Set swSelMgr = swModel.SelectionManager

    Set swFace = swSelMgr.GetSelectedObject5(1)

    

    vPickPt = swSelMgr.GetSelectionPoint(1)

    

    Set swPickPt = swMathUtil.CreatePoint((vPickPt))

    

    Set swModViewMgr = swModel.ModelViewManager

    

    

    Set swManip = swModViewMgr.CreateManipulator(swTriadManipulator, swDragHdlr)

    

    Set swTriad = swManip.GetSpecificManipulator

    

    swTriad.Origin = swPickPt

    

    swManip.Show swModel

    

    

End Sub

'----------------------------------------------------

Class modules

'-----------------------------------------------------------------------------

Option Explicit

Implements SwManipulatorHandler2

______________________________________________________________________________

Private Function SwManipulatorHandler2_OnDelete(ByVal pManipulator As Object) As Boolean

    Debug.Print "SwManipulatorHandler2_OnDelete"

End Function

______________________________________________________________________________

Private Sub SwManipulatorHandler2_OnDirectionFlipped(ByVal pManipulator As Object)

    Debug.Assert False

    Debug.Print "SwManipulatorHandler2_OnDirectionFlipped"

End Sub

______________________________________________________________________________

Private Function SwManipulatorHandler2_OnDoubleValueChanged(ByVal pManipulator As Object, ByVal Id As Long, Value As Double) As Boolean

    'Debug.Assert False

    Debug.Print "SwManipulatorHandler2_OnDoubleValueChanged"

    Debug.Print "  ID               = " & Id

    Debug.Print "  Value            = " & Value

End Function

______________________________________________________________________________

Private Sub SwManipulatorHandler2_OnEndDrag(ByVal pManipulator As Object)

    Debug.Print "SwManipulatorHandler2_OnEndDrag"

End Sub

______________________________________________________________________________

Private Sub SwManipulatorHandler2_OnEndDrag(ByVal pManipulator As Object, ByVal handleIndex As Long)

    Debug.Print "SwManipulatorHandler2_OnEndDrag"

    Debug.Print "  HandleIndex      = " & handleIndex

    

    If (handleIndex = swDragArrowManipulatorOptions_e.swDragArrowManipulatorDirection2) Then

        Debug.Print " Direction1"

    Else

        Debug.Print " Direction2"

    End If

End Sub

______________________________________________________________________________

Private Sub SwManipulatorHandler2_OnHandleRmbSelected(ByVal pManipulator As Object, ByVal handleIndex As Long)

    Debug.Print "SwManipulatorHandler2_OnHandleRmbSelected"

    Debug.Print "  handleIndex      = " + handleIndex

End Sub

______________________________________________________________________________

Private Sub SwManipulatorHandler2_OnHandleSelected(ByVal pManipulator As Object, ByVal handleIndex As Long)

    Debug.Print "SwManipulatorHandler2_OnHandleSelected"

    Debug.Print "  HandleIndex      = " + handleIndex

End Sub

______________________________________________________________________________

Private Sub SwManipulatorHandler2_OnItemSetFocus(ByVal pManipulator As Object, ByVal Id As Long)

    Debug.Assert False

    Debug.Print "SwManipulatorHandler2_OnItemSetFocus"

    Debug.Print "  ID               = " & Id

End Sub

______________________________________________________________________________

Private Function SwManipulatorHandler2_OnLmbSelected(ByVal pManipulator As Object) As Boolean

    Debug.Assert False

    Debug.Print "SwManipulatorHandler2_OnLmbSelected"

End Function

______________________________________________________________________________

Private Function SwManipulatorHandler2_OnStringValueChanged(ByVal pManipulator As Object, ByVal Id As Long, Value As String) As Boolean

    Debug.Assert False

    Debug.Print "SwManipulatorHandler2_OnStringValueChanged"

    Debug.Print "  ID               = " & Id

    Debug.Print "  Value            = " & Value

End Function

______________________________________________________________________________

Private Sub SwManipulatorHandler2_OnUpdateDrag(ByVal pManipulator As Object, ByVal handleIndex As Long, ByVal newPosMathPt As Object)

    Debug.Print "SwManipulatorHandler2_OnUpdateDrag"

    Debug.Print "  HandleIndex      = " & handleIndex

   

End Sub



Provide feedback on this topic

SOLIDWORKS welcomes your feedback concerning the presentation, accuracy, and thoroughness of the documentation. Use the form below to send your comments and suggestions about this topic directly to our documentation team. The documentation team cannot answer technical support questions. Click here for information about technical support.

* Required

 
*Email:  
Subject:   Feedback on Help Topics
Page:   Create Triad Manipulator Example (VBA)
*Comment:  
*   I acknowledge I have read and I hereby accept the privacy policy under which my Personal Data will be used by Dassault Systèmes

Print Topic

Select the scope of content to print:



x

We have detected you are using a browser version older than Internet Explorer 7. For optimized display, we suggest upgrading your browser to Internet Explorer 7 or newer.

 Never show this message again
x

Web Help Content Version: API Help (English only) 2013 SP05

To disable Web help from within SOLIDWORKS and use local help instead, click Help > Use SOLIDWORKS Web Help.

To report problems encountered with the Web help interface and search, contact your local support representative. To provide feedback on individual help topics, use the “Feedback on this topic” link on the individual topic page.