re: GetAll2 Method (ICustomPropertyManager)

It's my first time with the CustomPropertyManager and I'm just wondering is this right?

I am inserting an envelope in an assembly and then making it virtual before I go in and change the custom properties.

My complete code is below, but here's the relevant bit

<p>Debug.Print "Custom Properties"</p><p></p><p>    Set swCustPropMgr = swModel.Extension.CustomPropertyManager("Default")</p><p>    </p><p>    Dim Names As Variant</p><p>    Dim Types As Variant</p><p>    Dim Values As Variant</p><p>    Dim ResolvedValues As Variant</p><p>    Dim i As Integer</p><p>    </p><p>    With swCustPropMgr</p><p>        </p><p>        ls = .GetAll2(Names, Types, Values, ResolvedValues)</p><p>        Debug.Print "GetAll2 Status > Returned:"; ls</p><p>      </p><p>        Debug.Print " #", "Type", "ResolvedValue", "Value", "Name"</p><p>        Debug.Print String\\\$(80, "-")</p><p>        For i = 0 To ls - 1</p><p>            Debug.Print i + 1, Types(i), ResolvedValues(i), Values(i), Names(i)</p><p>        Next</p><p>    End With</p>

Why are all my resolved values = 2 ?

from the help file

<p>Dim instance As ICustomPropertyManager</p><p>Dim PropNames As System.Object</p><p>Dim PropTypes As System.Object</p><p>Dim PropValues As System.Object</p><p>Dim Resolved As System.Object</p><p>Dim value As System.Integer</p><p></p><p>value = instance.GetAll2(PropNames, PropTypes, PropValues, Resolved)</p>

As a brief aside I wasn't certain how to go about doing this and tried various methods.

I found that ActivateDoc3 reported an error if the file wasn't saved.  I didn't find this in the documenation.

2016 SOLIDWORKS API Help - swActivateDocError_e Enumeration

<p>ActivateDoc3 Status > Errors: 8 </p>

Anyway error or not, it still worked just the same, here's my code

Thanks for looking

<p>Option Explicit</p><p></p><p>Dim swApp As SldWorks.SldWorks</p><p>Dim swModel As SldWorks.ModelDoc2</p><p>Dim swPart As SldWorks.PartDoc</p><p>Dim swAssem As SldWorks.AssemblyDoc</p><p>Dim EnvelopeComponent As SldWorks.Component2</p><p>Dim swDimension As SldWorks.Dimension</p><p>Dim swCustPropMgr As SldWorks.CustomPropertyManager</p><p></p><p>Dim ls As Long, lw As Long</p><p>Dim bs As Boolean</p><p></p><p>Sub main()</p><p></p><p>     Set swApp = Application.SldWorks</p><p>    With swApp</p><p>    </p><p>        Set swModel = .NewDocument(DefaultAssTemplate, 0, 0, 0)</p><p>        </p><p>        bs = .RunCommand(swCommands_Save, "")</p><p>        </p><p>        Set EnvelopeComponent = swModel.InsertEnvelope(EnvelopeName, "", 0, 0, 0)</p><p>        </p><p>        swModel.ViewZoomtofit2</p><p>        </p><p>        bs = EnvelopeComponent.MakeVirtual2(False)</p><p>        </p><p>        bs = swModel.Save3(swSaveAsOptions_e.swSaveAsOptions_SaveReferenced _</p><p>                         , errors:=ls, warnings:=lw)</p><p>        Debug.Print _</p><p>                   ".Save3 Status > error:"; ls, "warning:"; lw</p><p>                   </p><p>        Set swModel = .ActivateDoc3(EnvelopeComponent.GetPathName _</p><p>                                  , UseUserPreferences:=False _</p><p>                                  , Option:=swRebuildOnActivation_e.swRebuildActiveDoc _</p><p>                                  , errors:=ls)</p><p>        Debug.Print _</p><p>                      "ActivateDoc3 Status > Errors:"; ls</p><p>    </p><p>    End With</p><p>    </p><p>Debug.Print "Custom Properties"</p><p></p><p>    Set swCustPropMgr = swModel.Extension.CustomPropertyManager("Default")</p><p>    </p><p>    Dim Names As Variant</p><p>    Dim Types As Variant</p><p>    Dim Values As Variant</p><p>    Dim ResolvedValues As Variant</p><p>    Dim i As Integer</p><p>    </p><p>    With swCustPropMgr</p><p>        </p><p>        ls = .GetAll2(Names, Types, Values, ResolvedValues)</p><p>        Debug.Print "GetAll2 Status > Returned:"; ls</p><p>      </p><p>        Debug.Print " #", "Type", "ResolvedValue", "Value", "Name"</p><p>        Debug.Print String\\\$(80, "-")</p><p>        For i = 0 To ls - 1</p><p>            Debug.Print i + 1, Types(i), ResolvedValues(i), Values(i), Names(i)</p><p>        Next</p><p>    End With</p><p></p><p>End Sub</p><p></p><p>Private Function EnvelopeName() As String</p><p>    EnvelopeName = swApp.GetCurrentMacroPathFolder & "\\" & "Default Table Top.SLDPRT"</p><p>End Function</p><p></p><p>Private Function DefaultAssTemplate() As String</p><p>    DefaultAssTemplate = swApp.GetUserPreferenceStringValue(swUserPreferenceStringValue_e.swDefaultTemplateAssembly)</p><p>End Function</p>
SolidworksApi macros