Hide Table of Contents

Create Triad Manipulator Example (VBA)

This example shows how to create a triad manipulator.

'----------------------------------------------------------------------------
' Preconditions:
' 1. Click Tools > References > SolidWorks 2015 exposed type libraries for
'    add-in use
(swpublished.tlb) and click OK.
' 2. Right-click the project name in the Project Explorer and click
'    Insert > Class Module.
' 3. Click Class1 in the Project Explorer.
' 4. Type swDragManipHdlr in (Name) in the Properties window.
' 5. Copy Module to the main module.
' 6. Copy Class module to the swDragManipHdlr class module.
' 7. Open a model document and select a face.
' 8. Open an Immediate window.
'
' Postconditions:
' 1. Creates a triad manipulator whose origin is the point
'    selected on the face.
' 2. Drag a triad manipulator handle and inspect the Immediate window.
'----------------------------------------------------------------------------

'Module

Option Explicit

 

Dim swManip                  As SldWorks.Manipulator

Dim swTriad                  As SldWorks.TriadManipulator

Dim swDragHdlr               As swDragManipHdlr

Dim 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.GetSelectedObject6(1, -1)

    

    vPickPt = swSelMgr.GetSelectionPoint2(1, -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

 

Back to top

'Class module

Option Explicit

Implements SwManipulatorHandler2

 

Private Function SwManipulatorHandler2_OnDelete(ByVal pManipulator As Object) As Boolean

    Debug.Print "Manipulator deleted"

End Function

 

Private Sub SwManipulatorHandler2_OnDirectionFlipped(ByVal pManipulator As Object)

    Debug.Print "Direction flipped"

End Sub

 

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

    Debug.Print "Double value changed "

    Debug.Print "  Value            = " & Value

End Function

 

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

    Debug.Print "Mouse button released"

    Debug.Print "  HandleIndex  as defined in swTriadManipulatorControlPoints_e    = " + handleIndex


End Sub

 

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

    Debug.Print "Mouse button released after dragging a manipulator handle"

End Sub

 

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

    Debug.Print "Right-mouse button clicked"

    Debug.Print "  HandleIndex as defined in swTriadManipulatorControlPoints_e     = " + handleIndex

End Sub

 

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

    Debug.Print "Manipulator handle selected"

    Debug.Print "  HandleIndex      = " + handleIndex

End Sub

 

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

    Debug.Print "Focus set on item"

    Debug.Print "  Item ID               = " & Id

End Sub

 

Private Function SwManipulatorHandler2_OnHandleLmbSelected(ByVal pManipulator As Object) As Boolean

    Debug.Print "Left-mouse button clicked"

End Function

 

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

    Debug.Print "String value changed"

    Debug.Print "  Value            = " & Value

End Function

 

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

    Debug.Print "Manipulator handle moved while left- or right-mouse button depressed"

    Debug.Print "  HandleIndex as defined in swTriadManipulatorControlPoints_e     = " & handleIndex

End Sub

Back to top



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) 2015 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.