WasResolved from Get6 (CustomPropertyManager)

Programming and macros
User avatar
mihkov
Posts: 44
Joined: Sun Feb 05, 2023 2:01 am
Answers: 0
x 17
x 24

WasResolved from Get6 (CustomPropertyManager)

Unread post by mihkov »

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?

Code: Select all

From general properties (not configuration)
Property: val1 / Value: "SW-Mass@Part.SLDPRT" / Resolved Value: 174.47 / Was Resolved: True
---
Property: val2 / Value: "SW-Mass" / Resolved Value: 174.47 / Was Resolved: True
---
Property: val3 / Value: "SW-Masss" / Resolved Value: "SW-Masss" / Was Resolved: True
---
Property: val4 / Value: "SW-Wasistdas" / Resolved Value: "SW-Wasistdas" / Was Resolved: True
---
Property: val5 / Value: "TT@mm" / Resolved Value: "TT@mm" / Was Resolved: True
---
Property: val6 / Value: "D567@Sk976" / Resolved Value: "D567@Sk976" / Was Resolved: True

From configuration properties
Configuration Property: val1c / Value: "SW-Mass@@ConfName@Part.SLDPRT" / Resolved Value: 174.47 / Was Resolved: True
---
Configuration Property: val2c / Value: "SW-Mass@Part.SLDPRT" / Resolved Value: 174.47 / Was Resolved: True
---
Configuration Property: val3c / Value: "SW-Mass" / Resolved Value: 174.47 / Was Resolved: True
---
Configuration Property: val4c / Value: "SW-Masss" / Resolved Value: "SW-Masss" / Was Resolved: True
---
Configuration Property: val5c / Value: "TT@mm" / Resolved Value: "TT@mm" / Was Resolved: True
---
Configuration Property: val6c / Value: "D567@Sk976" / Resolved Value: "D567@Sk976" / Was Resolved: True
---
User avatar
AlexB
Posts: 502
Joined: Thu Mar 18, 2021 1:38 pm
Answers: 28
x 269
x 446

Re: WasResolved from Get6 (CustomPropertyManager)

Unread post by AlexB »

The remarks section on the help page explain the scenarios where the resolved value can return false
https://help.solidworks.com/2018/englis ... ~get6.html
User avatar
mihkov
Posts: 44
Joined: Sun Feb 05, 2023 2:01 am
Answers: 0
x 17
x 24

Re: WasResolved from Get6 (CustomPropertyManager)

Unread post by mihkov »

AlexB wrote: Fri Jan 26, 2024 8:28 am The remarks section on the help page explain the scenarios where the resolved value can return false
https://help.solidworks.com/2018/englis ... ~get6.html
I imitated these conditions and got WasResolved=True
User avatar
Stefan Sterk
Posts: 37
Joined: Tue Aug 10, 2021 2:40 am
Answers: 3
x 51
x 77

Re: WasResolved from Get6 (CustomPropertyManager)

Unread post by Stefan Sterk »

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.
image.png
Used the code below to create the resultes in immediate windows.

Code: Select all

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
User avatar
mihkov
Posts: 44
Joined: Sun Feb 05, 2023 2:01 am
Answers: 0
x 17
x 24

Re: WasResolved from Get6 (CustomPropertyManager)

Unread post by mihkov »

Stefan Sterk wrote: Tue Jan 30, 2024 4:24 pm 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.

Well, what can I say: it was so, it is so, and it will be so forever and ever.
Post Reply