Hide Table of Contents

Insert Mate Reference Example (VB.NET)

This example shows how to insert a mate reference.

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

' Preconditions: Open:

' <SOLIDWORKS_install_dir>\samples\HandsOn\mate references\crank-arm.sldprt

'

' Postconditions:

' A mate reference, MateReference1, is inserted in the MateReferences folder

' in the FeatureManager design tree.

' NOTE: Because this part is used in a SOLIDWORKS online tutorial,

' do not save any changes when you close it.

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

Imports SolidWorks.Interop.sldworks

Imports SolidWorks.Interop.swconst

Imports System

Partial Class SolidWorksMacro

    

    Sub main()

        Dim swModel As ModelDoc2

        Dim swModelDocExt As ModelDocExtension

        Dim swSelMgr As SelectionMgr

        Dim swFeatMgr As FeatureManager

        Dim swFeature As Feature

        Dim mateRef1 As Object, mateRef2 As Object, mateRef3 As Object

        Dim boolstatus As Boolean

        Dim strMateRefName As String

        swModel = swApp.ActiveDoc

        swModelDocExt = swModel.Extension

        swSelMgr = swModel.SelectionManager

        swFeatMgr = swModel.FeatureManager

        swModel.ClearSelection2(True)

        ' Select three faces

        boolstatus = swModel.Extension.SelectByID2("", "FACE", 0.007841429441271, 0.004702510345794, 0.007840974544081, False, 0, Nothing, 0)

        mateRef1 = swSelMgr.GetSelectedObject6(1, -1)

        boolstatus = swModel.Extension.SelectByID2("", "FACE", 0.06256195446167, 0.003271675226301, 0.004687091733047, False, 0, Nothing, 0)

        mateRef2 = swSelMgr.GetSelectedObject6(1, -1)

        boolstatus = swModel.Extension.SelectByID2("", "FACE", 0.04319534991731, 0.006350000000054, 0.009894144482189, False, 0, Nothing, 0)

        mateRef3 = swSelMgr.GetSelectedObject6(1, -1)

        swModel.ClearSelection2(True)

        strMateRefName = "MateReference1"

        ' Insert mate reference

        swFeature = swFeatMgr.InsertMateReference2(strMateRefName, mateRef1, swMateReferenceType_e.swMateReferenceType_Concentric, swMateReferenceAlignment_e.swMateReferenceAlignment_Aligned, False, mateRef2, swMateReferenceType_e.swMateReferenceType_Concentric, swMateReferenceAlignment_e.swMateReferenceAlignment_AntiAligned, False, mateRef3, swMateReferenceType_e.swMateReferenceType_Concentric, swMateReferenceAlignment_e.swMateReferenceAlignment_Closest)

        If swFeature Is Nothing Then

            MsgBox("Failed to insert mate reference.")

        End If

        swModel.ClearSelection2(True)

    End Sub

   

    Public swApp As SldWorks

End Class



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:   Insert Mate Reference (VB.NET)
*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.