Hi all
Given the responsiveness of everyone on this forum I take this opportunity to ask a question and not stay stuck for hours ...
I am currently trying to recover the mass of the parts via the Document Manager but I am experiencing a slight problem!
To be able to explain in a little more detail, here is the code:
Const key As String = "CLEF_DOCUMENT_MANAGER"
Dim swDmClassFactory As SwDocumentMgr.swDmClassFactory
Dim swDmApp As SwDocumentMgr.SwDMApplication
Dim docType As SwDmDocumentType
Dim FilePath As String
Dim allowReadOnly As Boolean
Dim result As SwDmDocumentOpenError
Dim DocProp As SwDMDocument
Dim Config As SwDMConfiguration
Dim GestConfig As SwDMConfigurationMgr
Dim bret As SwDmMassPropError
Sub Test()
Set swDmClassFactory = CreateObject("SwDocumentMgr.SwDMClassFactory")
If Not swDmClassFactory Is Nothing Then
Set swDmApp = swDmClassFactory.GetApplication(key)
FilePath = "CHEMIN_PRT"
Set DocProp = swDmApp.GetDocument(FilePath, swDmDocumentPart, False, result)
Set GestConfig = DocProp.ConfigurationManager
Set Config=GestConfig.GetConfigurationByName(GestConfig.GetActiveConfigurationName)
valeurs = Config.GetMassProperties(bret)
Debug.Print "Masse : " & valeurs(5)
DocProp.CloseDoc
Else
MsgBox "Erreur"
End If
End Sub
The problem is this: for some parts (without me being able to find any common points between those that don't work) the array ' values ' is filled with 0 while I have no error on the values of ' result ' and ' bret '. And when I open the document on SW and I look at the mass it is not zero, so I don't understand where the problem comes from
I should point out that I have verified that the version of the part is also correct as indicated in the API Help: GetMassProperties Method (ISwDMConfiguration) - 2022 - SOLIDWORKS API Help
Does anyone have a lead at any rate?
Thanks in advance