2 Replies Latest reply on Jan 7, 2015 4:38 PM by kate_lee

    Utility.NewLayerRanges ?


      Hi, in below script, if I use

      Set NewLayerRangesCol = UtilityObj.NewObjects

      it has no error

      but if I use

      Set NewLayerRangesCol = UtilityObj.NewLayerRanges

      it has an error for "Add" method.

      It seems to have problem to "Remove" either.


      How can I Add an object to 'NewLayerRangesCol/' Collection?




      Option Explicit


      ' Get the Application object

      Dim pcbAppObj

      Set pcbAppObj = Application


      ' Get the active document

      Dim pcbDocObj

      Set pcbDocObj = pcbAppObj.ActiveDocument








      Dim EditConObj

      Set EditConObj = pcbDocObj.EditorControl



      Dim UtilityObj

      Set UtilityObj = pcbAppObj.Utility


        Dim ePcbPadShapesArg

        ePcbPadShapesArg=Array("epcbRectPad", "epcbOblongPad", "epcbRoundPad", "epcbSquarePad", "epcbCustomPad")

        Dim EPcbECSelPadsViaPosRulesArgs, LayerRange3, Text5

        EPcbECSelPadsViaPosRulesArgs = Array("epcbECAllowViasUnderPad","epcbECAllowOffPadOrigin","epcbECAlignViaOnLongAxis","epcbECLocateViaAtPadEdge","epcbECKeepViaCenterInsidePad","epcbECKeepViaPadInsidePad")



        Dim i,j,PadsCol,Text1,PadsShapeCol,PadShape,Text7

        Dim LayerRange,LayerRangesCol,NewLayerRangesCol,NewLayerRangesObj,k,LayerRangesCol1,LayerRange1,m



        For j = 0 to 4

        Set PadsShapeCol = EditConObj.Pads(j)

        Text1 = Text1 & vbCrlf & "Pad Shape Type: " & ePcbPadShapesArg(j) & vbCrlf &_

        "->Pads Count: " & PadsShapeCol.count & vbCrlf


        For Each PadShape in PadsShapeCol

        'Set NewLayerRangesCol = UtilityObj.NewObjects

        Set NewLayerRangesCol = UtilityObj.NewLayerRanges

        Text1 = Text1 & " --> " & PadShape & vbCrlf


        Set LayerRangesCol = EditConObj.PadEntryViaSpansForPad(PadShape)




        For Each NewLayerRangesObj in NewLayerRangesCol

        Text1 = Text1 & NewLayerRangesObj & vbCrlf








        MsgBox Text1

        • 1. Re: Utility.NewLayerRanges ?

          I looked over the PCB Automation Reference and found that 'Add Method' is not mentioned for LayerRanges Collection, whereas it is addressed in most other collections. It might make sense that LayerRanges Collection does not allow adding a new entry, but then for what Utility.NewLayerRanges method is, that is to create a new, empty LayerRanges collection if the collection cannot get a new entry?

          It appears that removing unnecessary elements in LayerRangesCol above could make a workaround.

          1 of 1 people found this helpful
          • 2. Re: Utility.NewLayerRanges ?

            I succeed using "remove" method as per your comment. Thank you!