1 2 First Previous 20 Replies Latest reply on Dec 26, 2012 10:41 AM by al_layson

    How do I get the drill table and drill chart when using the NC Drill Engine in a vbscript?

    A.Ozenne

      Hello,

       

      I am trying to use the NC Drill Engine in a vbscript. I manage to create the output files but I can't get the drill chart and the drill table in the "Drill Drawing -Through" fabrication layer.

      I use the sample script provided with the documentation (see below) but I don't get anything. Am I missing something obvious? Is there something to enable? Is there another way to get the drill table with a vb script?

       

      Thanks

       

      Anthony

       

       

       

      Option Explicit
      
      ' Add type libraries
      Scripting.AddTypeLibrary("MGCPCBEngines.NCDrill")
      
      Dim pcbAppObj
      Dim pcbDocObj
      Set pcbAppObj = Application
      Set pcbDocObj = pcbAppObj.ActiveDocument
      
      ValidateServer(pcbDocObj)
      
      ' Global Variables
      Dim designNameStr
      designNameStr = pcbDocObj.FullName
      
      Call RunNCDrill()
      
      ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
      ' Main Functions
      
      Sub RunNCDrill()
          ' Create NCDrill Engine object
          Dim ncDrillEngineObj
          Set ncDrillEngineObj = CreateObject("MGCPCBEngines.NCDrill")
      
          ' Set the design file name
          ncDrillEngineObj.DesignFileName = designNameStr
          Call SetupNCDrillMachineFormat(ncDrillEngineObj)
          Call SetupNCDrillParameters(ncDrillEngineObj)
          Call SetupNCDrillChart(ncDrillEngineObj)
      
             ' There are many possible errors when running the engine.
          ' We will catch the case and display them on our own
          On Error Resume Next
          Err.Clear
      
          ' Run the NCDrill Engine
          ncDrillEngineObj.Go()
      
          If Err Then
              ' Check errors
              Dim errorColl
              Set errorColl = ncDrillEngineObj.Errors
              Dim errObj
              Dim errDisplayStr : errDisplayStr = ""
              For Each errObj In errorColl
                  errDisplayStr = errDisplayStr & vbCrLf & "-" & errObj.ErrorString
              Next
      
              If Not errDisplayStr = "" Then
                  MsgBox("Error(s) running NC Drill engine:" & vbCrLf & errDisplayStr)
              End If
          End If
      End Sub
      
      ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
      ' Utility functions
      
      ' Sets up an NC Drill machine format
      ' ncDrillEngineObj - NCDrill Object
      Sub SetupNCDrillMachineFormat(ncDrillEngineObj)
          Dim ncDrillMFObj
          Set ncDrillMFObj = ncDrillEngineObj.MachineFormat
      
          ' Setup MetricDrillMachineFormat.dff
          ncDrillMFObj.DataType = eengExcellon
          ncDrillMFObj.Unit = eengUnitMM
          ncDrillMFObj.DataFormatLeadingDigits = 3
          ncDrillMFObj.DataFormatTrailingDigits = 3
          ncDrillMFObj.StepMode = eengStepAbsolute
          ncDrillMFObj.ZeroTruncation = eengZeroTruncationLeading
          ncDrillMFObj.DataMode = TRUE
          ncDrillMFObj.ArcStyle= eengArcStyleRadius
          ncDrillMFObj.SequenceNumbering = FALSE
          ncDrillMFObj.CharacterSet = eengCharacterSetASCII
          ncDrillMFObj.Delimiter = ""
          ncDrillMFObj.Comments = TRUE
          ncDrillMFObj.CommentStr = "; "
          ncDrillMFObj.RecordLength = 0
      
          ' Optional, where to write the format file
          ncDrillMFObj.FileName = "ncDrillMachine.dff"
      End Sub
      
      ' Sets up NC Drill parameters
      ' ncDrillEngineObj - NCDrill Object
      Sub SetupNCDrillParameters(ncDrillEngineObj)
      
          Dim ncDrillParametersObj
          Set ncDrillParametersObj = ncDrillEngineObj.Parameters
      
          ' Same as the options in "Drill Options"
          ' tab of the "NC Drill Generation" dialog
          ncDrillParametersObj.SweepAxis = eengSweepaxisHorizontal
          ncDrillParametersObj.Bandwidth(eengUnitMM) =  2.54
          ncDrillParametersObj.PreDrillHolesLargerThan(eengUnitMM) =  5
          ncDrillParametersObj.OutputFileExtension = ".ncd"
          Call ncDrillParametersObj.ClearFileHeader()
          Call ncDrillParametersObj.ClearFileNotes()
          Call ncDrillParametersObj.AddFileHeader("")
          Call ncDrillParametersObj.AddFileNotes ("")
      End Sub
      
      ' Sets up the NCDrill chart.
      ' ncDrillEngineObj - NCDrill Object
      Sub SetupNCDrillChart(ncDrillEngineObj)
      
          Dim ncDrillChartObj
          Set ncDrillChartObj = ncDrillEngineObj.Chart
      
          ' Same as the options in "Drill Chart Options"
          ' tab of the "NC Drill Generation" dialog
          ncDrillChartObj.AllSpansOnSingleChart = false
          ncDrillChartObj.AssignDrillCharacters = false
          ncDrillChartObj.DrillSymbolsOnSeparateLayers = true
          ncDrillChartObj.FCFFontName = "VeriBest Gerber 0"
          ncDrillChartObj.FontName = "VeriBest Gerber 0"
          ncDrillChartObj.FontSize(eengUnitMM) =  2.5
          ncDrillChartObj.HorizontalLineSeparator =  false
          ncDrillChartObj.LineSpacing(eengUnitMM) = 2.5
          ncDrillChartObj.NegativeTolerance(eengUnitMM) =  0.05
          ncDrillChartObj.PenWidth(eengUnitMM) =  0.25
          ncDrillChartObj.PositiveTolerance(eengUnitMM) =  0.05
          ncDrillChartObj.PrecisionLeadingDigits = 1
          ncDrillChartObj.PrecisionTrailingDigits = 3
          ncDrillChartObj.SpecialNotes = ""
          ncDrillChartObj.TextFormatTitleCase = False
          ncDrillChartObj.Title = ""
          ncDrillChartObj.Unit = eengUnitsMetric
          ncDrillChartObj.VerticalLineSeparator = false
      
          Dim ncDrillChartObjColumns
          Set ncDrillChartObjColumns = ncDrillChartObj.Columns
      
          ncDrillChartObjColumns.Add(eengColumnSymbol)
          ncDrillChartObjColumns.Add(eengColumnDiameter)
          ncDrillChartObjColumns.Add(eengColumnTolerance)
          'ncDrillChartObjColumns.Add(eengColumnPlated)
          'ncDrillChartObjColumns.Add(eengColumnQuantity)
      
      End Sub
      
      
        1 2 First Previous