4 Replies Latest reply on Jun 22, 2012 10:15 AM by Craig Tsukuno

    Can I open a drawing in the vault w/o downloading a copy?

    Jeff Tyler

      Using VBA I understand how to save a copy of a drawing to my hard drive using PDMWorks.  Using VBA code with Sldworks I can then open it and extract General Table information into Excel.  To save a lot of processing time is it possible to simply open the drawing in the vault and fetch the table data without having to save a copy to the harddrive?   I guess what I want is to somehow set the PDMWDocument = a Modeldoc2 document.  Possible?

       

      Thanks, Jeff

        • Re: Can I open a drawing in the vault w/o downloading a copy?
          Jeff Holliday

          I know very little about using API but some about Workgroup. I doubt that you could do what you are hoping to do because Workgroup does not allow you to work on anything actually in the vault, only on files copied out.

          • Re: Can I open a drawing in the vault w/o downloading a copy?
            Wayne Matus

            The files in the Workgroup PDM vault are renamed, there is no file extension in the name. So there is not a way to open the file in the vault in SolidWorks. I have not tried, but you might be able to open them using the Document Manager API if you can decifer the location and the name of the actual file in the vault.

            • Re: Can I open a drawing in the vault w/o downloading a copy?
              Dan Miel

              Jeff,

              If you are saving a copy of the drawing to your hard drive and opening it in SolidWorks then I'm guessing that you are copying all of the reference files with the drawing. Instead of coping all of the files and opening it in SolidWorks I believe you can copy just the drawing file to your hard drive then I believe you can get the table information using the Document Manager like Wayne is suggesting.

              Dan Miel

              2010 SP04

              • Re: Can I open a drawing in the vault w/o downloading a copy?
                Craig Tsukuno

                For general tables, I use a macro in excel to copy all of the drawing files in a project folder to my hard drive, then have excel open solidworks and run a macro to get information from the general tables.  The key is when you download the drawing files from the vault to rename the extension and save a list of the file paths to perform the macro on.  Note that I do not go though the vault using the PDM api, \\serverName\vaultdata$\projects\

                 

                I later learned that this method does not work for BOM's due to the table not being able to update based on references, but it should work fine for general tables.

                 

                Eample code:  You need a reference to Microsoft scripting runtime 

                 

                 

                Sub DownloadVaultFiles(SearchFolder As String)

                'Dim objStartFolder As Variant
                objStartFolder = SearchFolder

                Dim objFSO, objPFolder, objSFolder, objSFolders, objDFolder
                Set objFSO = CreateObject("Scripting.FileSystemObject")
                Set objPFolder = objFSO.GetFolder(objStartFolder)
                Set objSFolders = objPFolder.SubFolders
                For Each objSFolder In objSFolders

                If Right(objSFolder.Name, 6) = "SLDDRW" Then
                    'wscript.echo objSFolder.Name
                    'strFilePath = GetLatestFile(objFSO.GetFolder(objSFolder.Path))
                    'wscript.echo strFilePath
                    'objFSO.CopyFile(strFilePath,strCopyToDirectory & "\" & objSFolder.Name & ".SLDDRW")
                    GetLatestFile objFSO.GetFolder(objSFolder.Path)
                End If

                Next

                End Sub

                Sub GetLatestFile(ByVal Folder)
                    strCopyToDirectory = "c:\temp\PDM BOM Export"
                   
                    Set objFSO = CreateObject("Scripting.FileSystemObject")
                    For Each Subfolder In Folder.SubFolders
                        'Wscript.Echo Subfolder.Path
                       
                        Set objFolder = objFSO.GetFolder(Subfolder.Path)
                        Set colFiles = objFolder.Files
                        For Each objFile In colFiles
                            If objFile.Name = "_SLDDRW" Then
                                If strFileName = "" Then
                                    strFileName = objFile.Name
                                    strModifiedDate = objFile.DateLastModified
                                    strPath = objFile.Path
                                End If
                                If objFile.DateLastModified > strModifiedDate Then
                                    strFileName = objFile.Name
                                    strModifiedDate = objFile.DateLastModified
                                    strPath = objFile.Path
                                End If
                            End If
                            'If objFile.Name = "_SLDDRW" Then
                                'Wscript.Echo objFile.Name
                                'Wscript.Echo objFile.DateLastModified
                            'End If
                            'Wscript.Echo objFile.Name
                        Next
                        'Wscript.Echo
                       
                    Next
                    'strFileName =
                    'GetLatestFile = strPath
                    arrfolder = Split(Folder, "\")
                    strPartName = arrfolder(UBound(arrfolder))
                    strPartName = Left(strPartName, Len(strPartName) - 7)
                    Sheets("Downloaded").Select
                    Dim lLastRow As Integer
                    lLastRow = Cells.SpecialCells(xlCellTypeLastCell).Rows.Row
                    Range("A" & lLastRow + 1).Value = strPartName
                    objFSO.CopyFile strPath, strCopyToDirectory & "\" & strPartName & ".SLDDRW"
                    Range("C" & lLastRow + 1).Value = strCopyToDirectory & "\" & strPartName & ".SLDDRW"
                    Range("B" & lLastRow + 1).Value = Now()
                End Sub