Hello!
How I can release macro for "Quantity parts selected in feature manager" in assembly?
I try this way (from help files of solidworks):
------------------------------
Option Explicit
Dim swApp As Object
Dim Part As Object
Dim swModel As SldWorks.ModelDoc2
Dim swModelDocExt As SldWorks.ModelDocExtension
Dim swSelMgr As SldWorks.SelectionMgr
Dim errors As Long
Dim warnings As Long
Dim selCount As Integer
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swModelDocExt = swModel.Extension
Set swSelMgr = swModel.SelectionManager
' Вызов подпрограммы подсчёта
QuantitySelectedParts
End Sub
Sub QuantitySelectedParts()
selCount = 0
swModelDocExt.SelectAll
selCount = swSelMgr.GetSelectedObjectCount2(-1)
Select Case swModel.GetType
Case swDocASSEMBLY
MsgBox "Количество выбранных деталей = " & selCount
Case Else
Debug.Print "Подсчёт деталей только в сборке"
End Select
End Sub
---------------------------------
It's work. But select ALL. I don't... I have no idea what to do.
Then why haven't they (Solidworks Company) done it already in status bar?
SolidworksApi macros