Is there a way to extract the file names saved a .pset file?

I am trying to create a vba code that extracts the name of files saved into a .pset. Is there anyway to open a .pset with out opening microstation. When i open with notepad its all in garbled coding language that i can not utilize the information.

Thanks!

Parents
  • Hi Emily (and Tom F),
    Here is the procedure (sorry for the formatting). To piggyback off what Tom said:

    1. Export the PSET onto your C drive.
    2. Change the file extension from .PSET to .ZIP (this requires the display of file extensions in Windows). “Yup folks, a PSET is merely a group of XML files disguised as a Zip file—how about that?”
    3. Create a new folder, name is irrelevant.
    4. Open the Zip file.
    5. Select all the .XML files that are in the 8-4-4-12 character format (0ba53d02-4f49-4266-b8b7-e680b0b0fd1f.xml, for example) and copy them.
    6. Open the new folder, paste them.
    7. From the address bar, highlight and copy the path.
    8. Open the Command Prompt.
    9. Type CD followed by a space, then paste in the path from Step 7, press Enter. (This should now reflect the path from Step 7.)
    10. Type find /i ".dgn" *.xml > output.txt
      1. Note that the files will be searched alphabetically, not in the order they were listed in the PSET.
    11. Open Output.txt in a robust text editor.
    12. Select all the lines, and sort alphabetically.
    13. Delete the short lines in the top-half of the list:

    14. Select the remaining lines and copy them:

    15. Open a blank spreadsheet and paste them into Cell A11 on the tab. While Column A is (still) highlighted, open the Data tab and click Text to Columns. On Step 2, use the less-than character as the (only) delimiter:

    16. When done, the (unfitted) columns should look like this:

    17. Find the column with the file names and paths; in this example it’s Column K:

    From here the rest is up to you. I like to paste this column into the spreadsheet I used to create the PSET; this allows me to check where the missing file(s) from the PSET are.

     

    Enjoy,

    LOR

  • LOR,

    Man, that is some impressive reverse engineering. That's going into the toolbox.

    Thanks!

    Tom F.

  • Shoot--I forgot one thing:

    I explored, and maybe continue to explore, creating ONE pset for EACH dgn, with the hopes--according to a CR filed a few years ago--that a tool to stitch PSETs together would exist by now (it doesn't, AFAIK). This sort-of solves The Problem by off-loading the PSETs to the individual user(s) (since they need to make check-prints).

    Why ONE pset for EACH dgn?

    • All drawings need to be printed, but usually not all at the same time (voided drawings, retired drawings, garbage drawings, etc.) Having 500 tiny PSETs is more valuable to me than being able to create one (or two or three or four...) PSETs in < 1 day.
    • I can easily connect "which PSETs" with the index (which also comes from PW), providing a super-PSET that prints in index order, at will.

    Aside from the missing stitching tool, the biggest problem here is:

    • creating a single PSET and printing it to a PDF takes about a minute (using MVBA), but
    • creating a PDF directly (also using MVBA) takes 10 seconds.

    This is tough to swallow for most project teams. Well, I guess Milton Friedman was right: there are no free lunches...

    LOR

  • FYI - I found that the extracted zip folder contains a file named "[Content_Types].xml", which lists an xml file for each pset member in the same order listed in the pset. Extracting the file names can be done simply by reading the first attribute of each xml listed in that "[Content_Types].xml" file.

    1. Save PSET
    2. Rename with .zip extension and extract folder
    3. Run ExtractfileNames macro
    4. Select extracted folder
    5. Go to "C:\temp\Extracted.Txt" to see extracted file names

    Sub ExtractFileNames()
    Dim XDoc As Object
    Dim XDoc2 As Object
    Dim xmlpath As String


    xmlpath = FolderSelectDialog("Select Folder", "C:\")

    Set XDoc = CreateObject("MSXML2.DOMDocument")
    XDoc.async = False: XDoc.validateOnParse = False
    XDoc.Load (xmlpath & "/[Content_Types].xml")

    'Get Document Elements
    Set lists = XDoc.documentElement
    For Each listnode In lists.childNodes
    If InStr(1, listnode.Attributes(0).Text, ".xml", vbTextCompare) Then
    Set XDoc2 = CreateObject("MSXML2.DOMDocument")
    XDoc2.async = False: XDoc2.validateOnParse = False
    XDoc2.Load (xmlpath & listnode.Attributes(0).Text)
    Set lists2 = XDoc2.documentElement
    If InStr(1, lists2.Text, ".dgn", vbTextCompare) Then
    WriteToFile2 lists2.childNodes(0).Text
    End If
    Set XDoc2 = Nothing
    End If
    Next listnode

    Set XDoc = Nothing
    End Sub
    Sub WriteToFile2(ExtractedName As String) 'Sub Function used to write substitution strings to text file
    Dim fso As Object
    Set fso = CreateObject("Scripting.FileSystemObject")
    If Not fso.FolderExists("C:\Temp\") Then
    fso.CreateFolder ("C:\Temp\")
    End If
    If Dir("C:\Temp\Extracted.txt") <> "" Then
    Open "C:\Temp\Extracted.Txt" For Append As #1
    Else
    Open "C:\Temp\Extracted.Txt" For Output As #1
    End If

    Print #1, Chr(34) & ExtractedName & Chr(34) 'Chr(34) adds quotation marks
    Close #1
    End Sub

    Public Function FolderSelectDialog(sCaption As String, sDefaultFolder As String)
    Const HWND As Long = 0
    Const NO_OPTIONS As Long = 0
    Dim oShell As Object, oFolder As Object, sFileSpec As String
    Set oShell = CreateObject("Shell.Application")
    Set oFolder = oShell.BrowseForFolder(0, sCaption, 0, CStr(sDefaultFolder))
    If Not oFolder Is Nothing Then
    sFileSpec = oFolder.Items.Item.Path
    End If
    FolderSelectDialog = sFileSpec
    Set oFolder = Nothing
    Set oShell = Nothing
    End Function

    Note: VBA References should include Microsoft Scripting Runtime and Microsoft XML

  • Learned something new today! Nice work kids.

    Connect r17 10.17.2.61 self-employed-Unpaid Beta tester for Bentley

Reply Children
No Data