MACRO LIBRARY

Add width mate

Free public access. No account or subscription required.

Files

Add width mate

Code

Module: mMain

'Demonstrates how to create a width mate.
    
'Preconditions: Four faces are selected, with the first two belonging to one _
    of the selection sets and the other two belonging to the other set.
    
'Written by Keith Rice
'CADSharp LLC
'www.cadsharp.com
    
Sub main()
    Dim swApp As SldWorks.SldWorks
    Dim swModel As SldWorks.ModelDoc2
    Dim swAssy As SldWorks.AssemblyDoc
    Dim swSelMgr As SldWorks.SelectionMgr
    
    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set swAssy = swModel
    Set swSelMgr = swModel.SelectionManager
    
    'Mark each of the faces in the first selection set with 1 and
    'each of the faces in the second selection set with 2
    swSelMgr.SetSelectedObjectMark 1, 1, swSelectionMarkSet
    swSelMgr.SetSelectedObjectMark 2, 1, swSelectionMarkSet
    swSelMgr.SetSelectedObjectMark 3, 16, swSelectionMarkSet
    swSelMgr.SetSelectedObjectMark 4, 16, swSelectionMarkSet
    
    'Add the mate
    swAssy.AddMate5 swMateWIDTH, swMateAlignANTI_ALIGNED, False, Empty, Empty, Empty, _
        Empty, Empty, Empty, Empty, Empty, False, False, swMateWidth_Centered, Empty
    
    'Rebuild model
    swModel.EditRebuild3
End Sub