Bug: IFeatureStatistics property always points to the active visible document in the solidworks session

Run the following macro and observe the issue:

Dim swApp As SldWorks.SldWorks
Sub main()

Set swApp = Application.SldWorks

Dim swModel As ModelDoc2
Dim swFirstNonVisiblePartDocument As ModelDoc2

Set swModel = swApp.GetFirstDocument

While Not swModel Is Nothing

If swModel.GetType = SwConst.swDocumentTypes_e.swDocPART And swModel.Visible = False Then
 Set swFirstNonVisiblePartDocument = swModel
 Set swModel = Nothing
Set swModel = swModel.GetNext
End If

Debug.Print "Found: " & swFirstNonVisiblePartDocument.GetTitle

Dim Statistics As SldWorks.FeatureStatistics

Set Statistics = swFirstNonVisiblePartDocument.FeatureManager.FeatureStatistics

Debug.Print Statistics.PartName

End Sub

The printed part name will be of the top-level assembly and not the part document.

This bug is so annoying because its workaround requires activating the part document to get the stats which is sooooo slow. Imagine having 300 part documents to show…

This is an odd one. I ran your test code and then started digging into other attributes. It turns out that if the file’s “Visible” attribute is False, then it’s loaded into memory only. GetPathName doesn’t return anything at all.

I feel like you may be stuck having to load the model in some capacity in order to get correct information.

Yup. That’s what I’m doing right now. I’m making the document visible so it is active. I am waiting for SW to confirm this.

This has been confirmed by SOLIDWORKS as a bug. Doubt it will be fixed any time soon.

Dear Amen,

I am able to reproduce the issue at my end and yes its a bug.

The method is pointing to the assembly instead it should point a part of the assembly I tried running through a loops of parts in assembly and I got the same results.

We already have a SPR for it. The SPR number is 1126583.

I have also attached the SPR to your SR. You'll be notified once the SPR gets resolved.
1 Like