8 Replies Latest reply on Nov 25, 2008 1:30 PM by Christina Seay

    PDMWE API setvar question...

    Christina Seay
      I'm trying to do a setvar to set a variable value on a folder card.

      This is the part of my code that sets the variable:

      **********************************************************************************************
      CopiedFolderPath = vault.GetFolderFromPath(vault.RootFolderPath + "\Astec Purchased Parts\" + PartNumber + "\")
      CopiedFolderID = CopiedFolderPath.ID

      Dim SetVarfile As IEdmFolder5
      Dim varEnum As IEdmEnumeratorVariable8
      SetVarfile = vault.GetObject(EdmObjectType.EdmObject_Folder, CopiedFolderID)
      varEnum = SetVarfile.GetEnumeratorVariable
      varEnum.SetVar("Project Number", "", PartNumber)

      *********************************************************************************************

      I'm getting this error:
      Public member 'GetEnumeratorVariable' on type 'IEdmFolder6' not found.

      On this line:
      varEnum = SetVarfile.GetEnumeratorVariable

      ***********************************

      Does anyone know why I'm getting that error?
        • PDMWE API setvar question...
          Michael Dekoning
          You declared SetVarfile as an IEdmFolder5 and there is not a GetEnumeratorVariable method for this interface. Did you mean to use IEdmFile5?
          • PDMWE API setvar question...
            Christina Seay
            No... I'm trying to set a variable on a Folder Card... is there not a way to do that?
            • PDMWE API setvar question...
              varEnum = SetVarfile. That's all you need.
              • PDMWE API setvar question...
                Christina Seay
                Ok... I tried that and now I'm getting a new error... here's what I've got now:
                **************************************************************************************

                Dim SetVarfolder As IEdmFolder5
                Dim varEnumfolder As IEdmEnumeratorVariable8
                SetVarfolder = vault.GetObject(EdmObjectType.EdmObject_Folder, CopiedFolderID)
                varEnumfolder = SetVarfolder
                varEnumfolder.SetVar("Project Number", "@", PartNumber)
                varEnumfolder.CloseFile(True)

                **************************************************************************************

                Error message:
                InvalidCastException was handled
                Unable to cast COM object of type 'System.__ComObject' to interface type 'EdmLib.IEdmEnumeratorVariable8'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{183B3576-3408-401D-946D-ED3A8E8B207D}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

                *******************************************************************************************

                Error is on this line:
                varEnumfolder = SetVarfolder

                *******************************************************************************************

                Any thoughts?
                • PDMWE API setvar question...
                  Christina Seay
                  And just in case anyone else stumbles across this thread looking for how to do a setvar... I do have it working for setting a variable on a FILE card with this code in vb.net:
                  ***************************************************************************************************
                  (The user is entering PartNumber in a field on the form)
                  ***************************************************************************************************
                  CopiedFilePath = vault.GetFileFromPath(vault.RootFolderPath + "\Astec Purchased Parts\" + PartNumber.Text + "\" + PartNumber.Text + filetype)
                  CopiedFileId = CopiedFilePath.ID

                  Dim SetVarfile As IEdmFile5
                  Dim varEnum As IEdmEnumeratorVariable8
                  SetVarfile = vault.GetObject(EdmObjectType.EdmObject_File, CopiedFileId)
                  varEnum = SetVarfile.GetEnumeratorVariable
                  varEnum.SetVar("Project Number", "@", PartNumber)
                  varEnum.CloseFile(True)

                  **********************************************************************************************

                  When I get it working with a folder, I'll post that code back up in here too. You never can have too many examples when you're trying to learn how to do something new.
                  • PDMWE API setvar question...
                    Christina Seay
                    Ok... finally figured it out... same thing.. the ProjectNumber is coming from a field on the form:
                    *************************************************************************************************************

                    CopiedFolderPath = vault.GetFolderFromPath(vault.RootFolderPath + "\Astec Purchased Parts\" + PartNumber + "\")
                    CopiedFolderID = CopiedFolderPath.ID

                    Dim SetVarfolder As IEdmFolder6
                    Dim varEnumfolder As IEdmEnumeratorVariable6
                    SetVarfolder = vault.GetObject(EdmObjectType.EdmObject_Folder, CopiedFolderID)
                    varEnumfolder = SetVarfolder
                    varEnumfolder.SetVar("Project Number", "", PartNumber)

                    ******************************************************************************************************************

                    I did as Lee suggested and removed:
                    .GetEnumeratorVariable

                    But I also had to change:
                    Dim SetVarfolder As IEdmFolder5
                    Dim varEnumfolder As IEdmEnumeratorVariable8

                    To:
                    Dim SetVarfolder As IEdmFolder6
                    Dim varEnumfolder As IEdmEnumeratorVariable6

                    And remove:
                    varEnumfolder.CloseFile(True)

                    Apparently you only have to call the .CloseFile method for files and not for folders.

                    *****************************************************************************************************

                    Thanks everyone for your help in figuring this out!!!! I hope someone else will find this code helpful.
                    • PDMWE API setvar question...
                      Jeff Sweeney
                      Thanks for posting your results. I love code snippets!
                      • PDMWE API setvar question...
                        Christina Seay
                        Me too!! You really never can have enough examples of code.

                        You know what.. that's what we should do... set up a thread of nothing but code snippets... that'd be fabulous... lol