Files
Lesson 3.2 homework part A solution
Code
'Homework 3.2a
'Create or use a part with multiple configurations in which the geometry is different. _
Write a macro that cycles through each configuration and prints the name of the _
configuration and the mass for that given configuration to the immediate window. _
Use the IMassProperty interface to get the mass information. Hint: Your MassProperty _
object variable needs to be reset for each configuration.
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swMassProp As SldWorks.MassProperty
Dim vConfigNames As Variant
Dim i As Integer
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
vConfigNames = swModel.GetConfigurationNames
For i = 0 To UBound(vConfigNames)
Set swMassProp = swModel.Extension.CreateMassProperty
swModel.ShowConfiguration2 vConfigNames(i)
Debug.Print vConfigNames(i) & ": " & swMassProp.Mass
Next i
End Sub