6 Replies Latest reply on Aug 18, 2017 3:36 AM by Denis Messager

    how can I get getenumeratorvariable command for a folder ?

    Denis Messager

      Hello I made some reseach on the API help and on the forums without sucess.

      I make an Excel macro to sort all the emails stored in a specific folder. I would like to get a card value of the folder.

      The function "GetEnumeratorVariable" is available for a IEdmFile but not for EdmFolder. But in the help documentation, it says this is same way to access file or folder.

       

      What am I missing?

       

      Thank you for your help.

        • Re: how can I get getenumeratorvariable command for a folder ?
          Alex Burnett

          This appears to be answered here. Let me know if this works for you.

           

          https://forum.solidworks.com/thread/98813

            • Re: how can I get getenumeratorvariable command for a folder ?
              Denis Messager

              Hi Alex,

               

              Thank you for helping me.

               

              I've found this thread when I made my researches, it looks to work in C# but in VBA it doesn't.

              For example, I declare my variables :

              • dim MonFichier As IEdmFile11
              • Dim MonDossier As IEdmFolder9
              • Dim varEnum As IEdmEnumeratorVariable5

               

              Set varEnum = MonFichier.GetEnumeratorVariable works but Set varEnum = MonDossier.GetEnumeratorVariable doesn't.

              If I go though it, I get a VBA message like 'property not handled'

               

              Even the VBA editor proposes me the method GetEnumeratorVariable for MonFichier and doesn't for MonDossier.

                • Re: how can I get getenumeratorvariable command for a folder ?
                  Alex Burnett

                  In the example, the folder is set directly as the IEdmEnumieratorVariable5 object. It does not have a GetEnumeratorVariable function. Try the following.

                   

                  Set varEnum = MonDossier.GetEnumeratorVariable

                   

                  I tried implementing this with my C# add-in to check and get variables and the above step worked for me. I did run into a problem with the GetVar function returning null values so I don't know exactly how to get the variables you're looking for as a list you can browse through.

                    • Re: how can I get getenumeratorvariable command for a folder ?
                      Denis Messager

                      Thanks, it works, no more problem to set the IEdmEnumeratorVariable5 variable.

                       

                      But as you noticed, the getvar function return always 'nothing' values. I double checked my variable name.

                                         

                                          Dim VariableValue As IEdmVariableValue6

                                          Set varEnum = MonDossier

                                          Call varEnum.GetVar("DESCRI_FRA", Empty, VariableValue)

                                          If Not VariableValue Is Nothing Then

                                              MsgBox ("OK")

                                          End If

                        • Re: how can I get getenumeratorvariable command for a folder ?
                          Alex Burnett

                          Okay, it looks like I can get it to work with "Date" and "Author", however it doesn't appear to work with my other variables. I don't know if it is because they are blank on my folder because I can't edit that for testing. Hopefully you can get it working the way you need it to. If it helps, here's the code I used to get the date.

                           

                          efile = vault.GetFileFromPath(modelIn.FilePath, out efolder);

                           

                           

                                          IEdmEnumeratorVariable5 ie5 = (IEdmEnumeratorVariable5)efolder;

                                          object foldervarval;

                                          ie5.GetVar("Date", string.Empty, out foldervarval);

                                          if(foldervarval != null)

                                              Trace.WriteLine("Folder Project Num: [" + foldervarval.ToString() + "]");

                            • Re: how can I get getenumeratorvariable command for a folder ?
                              Denis Messager

                              Hi Alex,

                              Thank you a lot for helping me. You found the solution !

                               

                                                 Dim VariableValue As variant

                                                  Set varEnum = MonDossier

                                                  Call varEnum.GetVar("DESCRI_FRA", Empty, VariableValue)

                                                  If Not IsEmpty(VariableValue) Then

                                                      MsgBox ("my value : " & CStr(VariableValue))

                                                  End If

                               

                              I can now move forward on my Excel sheet. It's been a pleasure to work on this with you.

                              I hope it could help the API community with this VBA code.