How does Solidworks software decide which expression could be evaluated and which could not?
We are talking about the function Get6(Get5) of reading user properties through the CustomPropertyManager interface
value = instance.Get6(FieldName, UseCached, ValOut, ResolvedValOut, WasResolved, LinkToProperty)
value: swCustomInfoGetResult_ResolvedValue = 2 = (WasResolved=True) [Resolved value was returned]
I made the configuration from which I read the properties inactive and not rebuilt, and if UseCached = False the configuration is rebuilt and I get good mass values, and if True, then I get zeros in the calculated mass values. But “Was Resolved” always the True. How do you even get a False?
I also tried to imitated these conditions, and also got only TRUE values for WasResolved, since the value cleary wasn’t as is shown in the attached image below. Using SOLIDWORKS 2023.
Used the code below to create the resultes in immediate windows.
Option Explicit
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swDoc As SldWorks.ModelDoc2
Dim swPrpMgr As SldWorks.CustomPropertyManager
Dim sPrpNames As Variant
Dim sPrpName As Variant
Set swApp = Application.SldWorks
Set swDoc = swApp.ActiveDoc
If swDoc Is Nothing Then End
Set swPrpMgr = swDoc.Extension.CustomPropertyManager("")
Debug.Print "Name Active Configuration: " & swDoc.GetActiveConfiguration().Name
Debug.Print "## USE CACHED = TRUE ##"
sPrpNames = swPrpMgr.GetNames
For Each sPrpName In sPrpNames
PrintPrps swDoc, CStr(sPrpName), True
Next
Debug.Print "## USE CACHED = FALSE ##"
For Each sPrpName In sPrpNames
PrintPrps swDoc, CStr(sPrpName), False
Next
End Sub
Function PrintPrps(swDoc As SldWorks.ModelDoc2, sPrpName As String, Optional UseCached As Boolean = True)
Dim swPrpMgr As SldWorks.CustomPropertyManager
Debug.Print sPrpName
' General Property
Set swPrpMgr = swDoc.Extension.CustomPropertyManager("")
PrintPrp swPrpMgr, sPrpName, UseCached
Dim sCfgNames As Variant
Dim sCfgName As Variant
' Configuration Specific Property
sCfgNames = swDoc.GetConfigurationNames
For Each sCfgName In sCfgNames
'Set swPrpMgr = swDoc.GetConfigurationByName(sCfgName).CustomPropertyManager
Set swPrpMgr = swDoc.Extension.CustomPropertyManager(sCfgName)
PrintPrp swPrpMgr, sPrpName, UseCached
Next sCfgName
Debug.Print ""
End Function
Function PrintPrp(swPrpMgr As SldWorks.CustomPropertyManager, sFieldName As String, Optional UseCached As Boolean = True)
Dim ValOut As String
Dim ResolvedValOut As String
Dim WasResolved As Boolean
Dim LinkToProperty As Boolean
Dim lRet As Long
lRet = swPrpMgr.Get6(sFieldName, UseCached, ValOut, ResolvedValOut, WasResolved, LinkToProperty)
Select Case lRet
Case 0 'swCustomInfoGetResult_CachedValue 0 = Cached value was returned
Debug.Print "Cached - " & WasResolved, ResolvedValOut, ValOut
Case 1 'swCustomInfoGetResult_NotPresent 1 = Custom property does not exist
Debug.Print "Missing - " & WasResolved, ResolvedValOut, ValOut
Case 2 'swCustomInfoGetResult_ResolvedValue 2 = Resolved value was returned
Debug.Print "Resolved - " & WasResolved, ResolvedValOut, ValOut
End Select
End Function