1 Reply Latest reply on Feb 17, 2014 2:19 PM by Anna Wood

    Help with Batch plot routine

    Larry Blakely

      Hello,

      I have tried to write a batch plot routine to use Edrawings Axcontrol to plot drawing to PDF's.

      The currrent problem is after running a few prints I get HashStack errors...and the program closes.

      Can anyone offer me a clue as to how to prevent this.... or a better solution.

      Any help appreciated. Thanks.

       

      The basic print call is as follows

       

      For V_x As Integer = 0 To BomDataTable.Rows.Count - 1

                  If BomDataTable.Rows(V_x).Item("PartNum").ToString.Length = 12 Then

                      FileName2 = V_SaveFolder & "\TempJobs\" & BomDataTable.Rows(V_x).Item("PartNum") & ".SLDDRW"

                      If System.IO.File.Exists(FileName2) = False Then

                          MsgBox("File Not Found : " & FileName2)

                          Continue For

                      End If

                      Me.Label4.Text = "Processing : " & BomDataTable.Rows(V_x).Item("PartNum")

                      Me.Label4.Refresh()

                      Fname = BomDataTable.Rows(V_x).Item("PartNum")

                      AxEModelViewControl1.Focus()

                      AxEModelViewControl1.OpenDoc(FileName2, False, False, True, "")

                      PDFPRINT2(Fname) 'Call Print Sub

                      AxEModelViewControl1.CloseActiveDoc("")

                      System.Threading.Thread.Sleep(1000)

                      Application.DoEvents()

                  End If

                  Application.DoEvents()

                  Me.Label4.Text = "Processing : " & BomDataTable.Rows(V_x).Item("PartNum")

                  Me.Label4.Refresh()

      Next V_x

       

      Private Sub PDFPRINT2(ByVal Name As String)

       

              V_TPageS = AxEModelViewControl1.SheetCount

              For V_x = 1 To V_TPageS + 1 'loop for the .drw files

                  AxEModelViewControl1.ShowSheet(V_x)

                  If V_x = V_TPageS + 1 Then

                      SName = AxEModelViewControl1.get_SheetName(0)

                      AxEModelViewControl1.ShowSheet(0)

                      W = AxEModelViewControl1.SheetWidth

                      H = AxEModelViewControl1.SheetHeight

                  Else

                      SName = AxEModelViewControl1.get_SheetName(V_x)

                  End If

                  W = AxEModelViewControl1.SheetWidth

                  H = AxEModelViewControl1.SheetHeight

                  If W = 17 Then

                      PaperSize = PaperKind.Tabloid

                  ElseIf W = 11 Then

                      PaperSize = PaperKind.A4

                  End If

                  AxEModelViewControl1.SetPageSetupOptions(EMVPrintOrientation.eLandscape, PaperSize, W, H, 1, 0, "PDFCreator", 0, 0, 0, 0)

                  AxEModelViewControl1.Print4(False, Name & SName, True, False, False, EMVPrintType.eScaleToFit, 0.0, 0, 0, False, V_x, V_x)

                  Application.DoEvents()

                  System.Threading.Thread.Sleep(500)

                  newcount = newcount + 1

                  Me.Label_PrntIts.Text = newcount

              Next

          End Sub