ModelDoc2::EditSuppress2

Sub main()

    Dim swApp               As SldWorks.SldWorks

    Dim swModel             As SldWorks.ModelDoc2

    Dim swSelMgr            As SldWorks.SelectionMgr

    Dim swFeat              As SldWorks.Feature

    Dim i                   As Long

    Dim bRet                As Boolean

   

    On Error Resume Next

   

    Set swApp = Application.SldWorks

    Set swModel = swApp.ActiveDoc

    Set swSelMgr = swModel.SelectionManager

   

    Debug.Print "File = " & swModel.GetPathName

    Debug.Print swSelMgr.GetSelectedObjectCount

    ' Information about selected entities

    For i = 1 To swSelMgr.GetSelectedObjectCount

        Set swFeat = swSelMgr.GetSelectedObject5(i)

       

        Debug.Print "  SelType(" & i & ") = " & swSelMgr.GetSelectedObjectType(i)

        If Not swFeat Is Nothing Then

            Debug.Print "    " & swFeat.Name & " <" & swFeat.GetTypeName & ">"

        End If

    Next i

    Debug.Print ""

   

    ' Suppress what has been selected

    bRet = swModel.EditSuppress2: Debug.Assert bRet

End Sub

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

Program operation results

Debug.print results

File = F:\\BE(J)S\\BES1800-2.5-1365-9/25-2I\\件号1管箱.sldasm

1

  SelType(1) = 20

--------------------

Another program method

------------

Dim swApp As Object
Dim Part As Object
Dim SelMgr As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Dim Feature As Object
Sub main()

Set swApp = Application.SldWorks

Set Part = swApp.ActiveDoc
Set SelMgr = Part.SelectionManager
boolstatus = Part.Extension.SelectByID2("管箱容积-1@件号1管箱", "COMPONENT", 0, 0, 0, False, 0, Nothing, 0)
Part.EditSuppress
Part.ClearSelection2 True
End Sub

SolidworksApi macros