9 Replies Latest reply on Sep 30, 2014 11:37 AM by Roger Palmen

    Converting PI-PB displays to SVG, automated routine

    Børre Heggernes

      Hi,

       

      anyone with experience of a VBA script that can automate the process of taking a .PIW file and automatically creating SVG's from all displays contained in it?

       

      We have a large .PIW file (100s of displays). Manual open and Save As.. operation will take a while. Has anyone tried some auto, or semi-auto, way of doing this?

       

       

       

      /Børre

        • Re: Converting PI-PB displays to SVG, automated routine
          Ahmad Fattahi

          You can look into SaveAs and pick SVG as the desired format. Something of this sort:

          
          

          ThisDisplay.SaveAs("filename", pbpdFormatSVG)

            • Re: Converting PI-PB displays to SVG, automated routine
              Asle Frantzen

              Wouldn't that imply embedding this line of code into every PB-file?

               

               

               

              We need something which doesn't require manual operation at all. Maybe a PB plugin?

                • Re: Converting PI-PB displays to SVG, automated routine

                  You could run the following from a display or from an Excel sheet etc providing you have references to the PBObjLib and PBSymLib...

                  
                  

                  Sub ParseProcbook()

                  Const sDir As String = "C:\"

                  Dim app As PBObjLib.Application
                  Set app = New PBObjLib.Application
                      app.Visible = True

                  Dim pb As PBObjLib.ProcBook
                  Set pb = app.ProcBooks.Open(sDir & "MyTest.piw")

                  Dim e As Entry
                  For Each e In pb.Entries
                      ' Just processing embedded displays, not linked displays
                      If e.Type = 1 Then
                          Call e.Execute(False)
                         
                          Dim Disp As Display
                          Set Disp = app.ActiveDisplay
                              Call Disp.SaveAs(sDir & Split(Disp.Path, "!")(UBound(Split(Disp.Path, "!"))) & ".svg", pbpdFormatSVG)
                              Call Disp.Close(False)
                          Set Disp = Nothing
                      End If
                  Next e

                  Call pb.Close(False)
                  Set pb = Nothing

                  app.Quit
                  Set app = Nothing

                  End Sub

                   

                  Obviously you will need to modify the code to suit your needs.

              • Re: Converting PI-PB displays to SVG, automated routine
                andreas

                Mmhh - Borre,

                 

                that sits on my ToDo list for some weeks now. The basic idea is taking the Export.PDI that comes with ActiveView and modify it to save SVG's.

                 

                I did a little VB6 program years ago that takes all PDI's in one directory and saves them as SVG. This little VB6 programm did resize the PDI's because there were some issues in the visible area of an SVG compared to the PDI. and in addition it put a little PI value symbol in the corner to show the timestamp.

                 

                So my plan was combining these two...

                 

                 

                  • Re: Converting PI-PB displays to SVG, automated routine
                    AlistairFrith

                    I did this a few years ago, I had a 'Macros' display with lots of useful tools for the particular project. One of the tools took the active Book, opened each display in turn, sized the display (the saved SVG basically looks like the it does in Processbook at the time it is saved so you must ensure that you can see the entire display in the window, as Andreas hinted), saved it as SVG and closed it.

                     

                    If I get the chance, I may be able to find it but I can't promise!

                     

                    --- Alistair.

                     

                     

                      • Re: Converting PI-PB displays to SVG, automated routine
                        Børre Heggernes

                        Thanks guys, confirms at least there isn't a straight forward solution to it.

                         


                        @Rhys: we will see if we give that a try. Good starting point if we do

                         

                        @Andreas: Whatcha waiting for...Do it, get it of your ToDo list right away

                          • Re: Converting PI-PB displays to SVG, automated routine
                            andreas

                            @Borre: A first version is available here.

                              • Re: Converting PI-PB displays to SVG, automated routine
                                aksnk89

                                Hi All,

                                 

                                I have to convert 180 PDI displays to SVG so that i can use them on Webparts and also while converting the display i want ensure that the display are save in " Zoom= FitAll" mode. For this bulk conversion i had written the following basic code as per my undersatnding (Newbee) but unfortunately after converting some displays it hangs. Can anyone give this a try ?

                                 

                                Public Function FileList(Mask As String) As String()

                                 

                                   Dim file As String

                                 

                                   Dim sAns() As String

                                 

                                   Dim i As Integer

                                 

                                   file = Dir(Mask, vbNormal)

                                 

                                   i = 0

                                 

                                   While (file <> "")

                                 

                                       ReDim Preserve sAns(i) As String

                                 

                                       sAns(i) = file

                                 

                                       i = i + 1

                                 

                                       file = Dir

                                 

                                   Wend

                                 

                                   FileList = sAns

                                 

                                End Function

                                 

                                Private Sub cmdSvg_Click()

                                 

                                   Dim sarr() As String

                                 

                                   Dim path As String

                                 

                                   path = TextBox1.Text & "\"

                                 

                                   sarr = FileList(path & "*.pdi")

                                 

                                   For Each file In sarr

                                 

                                       Dim newfile As String

                                 

                                       newfile = Replace(file, ".pdi", ".svg", , , vbTextCompare)

                                 

                                       Dim d As Display

                                 

                                       Set d = Application.Displays.Open(path & file, True)

                                 

                                       d.Zoom = "FitAll"

                                 

                                       d.SaveAs path & newfile, pbpdFormatSVG

                                 

                                       d.Close (True)

                                 

                                   Next

                                 

                                End Sub