8 Replies Latest reply on Sep 29, 2017 3:49 AM by Amruta T.

    EPDM full file path and folder id

    Amruta T.

      Hello

       

      Is there a way to read folder id and full file path of selected file in EPDM vault

       

      I am trying below code but not works for me

       

      For Folder Id  -

      @

      folderId = ppoData(index).mlObjectID3

       

      For full file path -

      fileObject = poCmd.mpoVault.GetObject(EdmObjectType.EdmObject_File, ppoData(index).mlObjectID1)

        • Re: EPDM full file path and folder id
          Michael Dekoning

          Your code above to get the full file path returns the file object not the path. Based on the code you've shown and assuming this is VB.Net try this -

           

          folderObject = poCmd.mpoVault.GetObject(EdmObjectType.EdmObject_Folder, ppoData(index).mlObjectID3)

          fileObject = poCmd.mpoVault.GetObject(EdmObjectType.EdmObject_File, ppoData(index).mlObjectID1)

          fullpath = folderObject.LocalPath & "\" & fileObject.Name

          • Re: EPDM full file path and folder id
            Jacob Corder

            Sometimes the folder isn't available based on the Hook type you are using.

            as Michael Dekoning showed above this should work.

             

            here is what is available based on the hook type you are using.

            2017 SOLIDWORKS API Help - EdmCmdData Structure

              • Re: EPDM full file path and folder id
                Amruta T.

                HI Jacob

                How to read the full file path form file id?

                I am using  below command in plugins

                EdmCmdType.EdmCmd_Menu

                Thanks for support

                  • Re: EPDM full file path and folder id
                    Jacob Corder

                    Ok Use Artem Taturevich  post here to get the path of the parent folder

                     

                    Epdm api getfolder path from folderid

                     

                    the parent Folder ID is EDMCmDData.MLObjectID3

                    2017 SOLIDWORKS API Help - EdmCmdData Structure

                    Dim M_CMDData as EdmCmdData

                    1. Dim folder as IEDMFolder5 = vault.GetObject(EdmObjectType.EdmObject_Folder, M_CMDData.MLObjectID3) 
                    2. Dim Path as string = folder.LocalPath; 
                    3. Dim FileName as string = Path & "\" & M_CMDData.mbsStrData1
                    4. this should be the full path of the file

                     

                     

                    Use what Michael Dekoning stated above. it is a much better method

                     

                    it only works if a File is selected.

                     

                    if it is M_CMDData.MLObjectID1 = 0 then no file selected and you should process the whole folder

                     

                    you will need to get all the files in the folder if you want to support this type of transaction request.

                     

                      • Re: EPDM full file path and folder id
                        Amruta T.

                        Hello Jacob

                        Below is the code, folder id is coming blank here

                        fileId  coming correctly. Can you help to read file full path ?

                        Thanks for support

                        Code -

                                While index <= last

                                    If ppoData(index).mlObjectID1 = 0 Then

                                        message = message + "Folder: (ID="

                                        folderId = ppoData(index).mlObjectID3

                                        StrID = ppoData(index).mlObjectID2

                                        message = message + StrID + ") "

                                    Else

                                        message = message + "File: (ID="

                                        fileId = ppoData(index).mlObjectID1

                                        StrID = ppoData(index).mlObjectID1

                                        message = message + StrID + ") "

                                    End If

                                    fileName = ppoData(index).mbsStrData1.ToUpper()         

                                    message = message + ppoData(index).mbsStrData1

                                    index = index + 1

                                End While

                          • Re: EPDM full file path and folder id
                            Jacob Corder

                            This is what i use

                             

                            Try using this.

                            Dim FileNames() As String = Nothing

                             

                            Insert this into your area where you need the file names

                                      Dim FileNames() as string

                                      GetFileNamesFromPPOData(ppoData, FileNames, ThisVault, True, 3)

                             

                             

                            Add this Method to your code

                             

                            Public Sub GetFileNamesFromPPOData(ByVal ppodata As Array, ByRef FileNames() As String, ByVal ThisVault As EdmLib.IEdmVault13, ByVal FullFileNames As Boolean, ByVal ParFolderMlObjID As Integer)
                                    If Not ppodata Is Nothing Then
                                        ReDim FileNames(ppodata.Length - 1)
                                        Dim CMDData As EdmLib.EdmCmdData
                                        Dim ThisFolder As EdmLib.IEdmFolder7
                                        For i = LBound(ppodata) To UBound(ppodata)
                                            Try
                                                CMDData = ppodata(i)
                                                If FullFileNames  Then
                                                    ThisFolder = Nothing
                                                    FileNames(i) = CMDData.mbsStrData1
                                                    If FileNames(i).Contains(".") = True And FileNames(i).Contains("\") = True Then
                                                          'It is already full path file name
                                                    Else
                                                        Select Case ParFolderMlObjID
                                                            Case 1
                                                                ThisFolder = ThisVault.GetObject(EdmLib.EdmObjectType.EdmObject_Folder, CMDData.mlObjectID1)
                                                            Case 2
                                                                ThisFolder = ThisVault.GetObject(EdmLib.EdmObjectType.EdmObject_Folder, CMDData.mlObjectID2)
                                                            Case 3
                                                                ThisFolder = ThisVault.GetObject(EdmLib.EdmObjectType.EdmObject_Folder, CMDData.mlObjectID3) '
                                                        End Select
                            
                            
                                                        If ThisFolder Is Nothing Then
                                                            FileNames(i) = CMDData.mbsStrData1
                                                        Else
                                                            FileNames(i) = ThisFolder.LocalPath & "\" & CMDData.mbsStrData1
                                                        End If
                                                    End If
                            
                            
                                                Else
                                                    FileNames(i) = CMDData.mbsStrData1
                                                End If
                                            Catch exp As COMException
                                                If IsNothing(ThisVault) = False Then
                                                    Dim errorName As String = Nothing
                                                    Dim errorDesc As String = Nothing
                                                    ThisVault.GetErrorString(exp.ErrorCode, errorName, errorDesc)
                                                    ThisVault.MsgBox(0, "Error Happened at Get File Names From PPOData, Error Description: " & errorDesc & " ERROR NAME: " & errorName)
                                                Else
                                                    MsgBox("Error Happened at Get File Names From PPOData, The EPDM Vault Connection Was lost")
                                                End If
                                            End Try
                            
                            
                                        Next
                                    End If
                                End Sub
                            
                            • Re: EPDM full file path and folder id
                              Jacob Corder

                              then you can get the IEdmFile and Parent Folder ID from

                              2017 SOLIDWORKS API Help - GetFileFromPath Method (IEdmVault5)