7 Replies Latest reply on Aug 26, 2013 5:45 PM by Satoru

    How to add graphics object on user draft layer

    joseph.spang1

      Hi All,

       

      I'm trying to put crossline on the user layer called Unplaced Graphics Assembly in cell editor.

      In fact I'm able to put crossline on fabrication layer using this script:

       

      Sub Document_PutUserLayerGfx()
      Dim docObj,resultMess,geomObj,pntsArr,numPoints,newObj,layerObj
      Dim fabGfxObj,gfxObj

      ' collect document object

      Set docObj = GetLicensedDoc(app)
      If (docObj Is Nothing) Then Exit Sub

      'fill the Line with points

      ReDim pntsArr(2,8)
        numPoints = 2
        pntsArr(0,0) = -5.0   :pntsArr(1,0) = -5.0   :pntsArr(2,0) =    0.0
        pntsArr(0,1) = 5.0 :pntsArr(1,1) = 5.0   :pntsArr(2,1) =    0.0
      set fabGfxObj = docObj.PutFabricationLayerGfx( epcbFabAssembly, epcbSideTop,0.4,numPoints,pntsArr, False,Nothing,epcbUnitCurrent)

      ReDim pntsArr(2,8)
        numPoints = 2
      pntsArr(0,0) = -5.0 :pntsArr(1,0) = 5.0 :pntsArr(2,0) =    0.0
      pntsArr(0,1) = 5.0 :pntsArr(1,1) = -5.0 :pntsArr(2,1) =  0.0
      set fabGfxObj = docObj.PutFabricationLayerGfx( epcbFabAssembly, epcbSideTop,0.4,numPoints,pntsArr, False,Nothing,epcbUnitCurrent)

      If (Err) Then
        Call app.Gui.StatusBarText("An error occured while creating the object: " + vbNewLine + Err.Description,epcbStatusFieldError)
      Exit Sub

      Else
      resultMess = "Fabrication layer element was created"

      'select the object and fit it on the board

         fabGfxObj.selected = True
         docObj.ActiveView.SetExtentsToSelection
         fabGfxObj.selected = False

      'Update status bar

         Call app.Gui.StatusBarText(resultMess,epcbStatusField1)

      End If

      End Sub

       

      Thanks,

      Joseph

        • 1. Re: How to add graphics object on user draft layer
          Satoru

          Hi Joseph-san,

           

          Please check this code.

           

          Regards,

          Satoru

           

          Sub Document_PutUserLayerGfx()

              Dim docObj, resultMess, pntsArr, numPoints, layerObj

              Dim usrLayGfx

           

              ' collect document object

              Set docObj = GetLicensedDoc(app)

              If (docObj Is Nothing) Then Exit Sub

           

              'Check UserLayer Object

              Set layerObj = docObj.FindUserLayer("Graphics Assembly")

              If layerObj Is Nothing Then

                  'Create UserLayer Object

                  Set layerObj =  docObj.SetupParameter.PutUserLayer("Graphics Assembly")

              End If

           

              'fill the Line with points

              ReDim pntsArr(2,8)

              numPoints = 2

              pntsArr(0,0) = -5.0   :pntsArr(1,0) = -5.0   :pntsArr(2,0) =    0.0

              pntsArr(0,1) = 5.0 :pntsArr(1,1) = 5.0   :pntsArr(2,1) =    0.0

              set usrLayGfx = docObj.PutUserLayerGfx(layerObj, 0.4, numPoints, pntsArr, False, Nothing, epcbUnitCurrent)

           

              ReDim pntsArr(2,8)

              numPoints = 2

              pntsArr(0,0) = -5.0 :pntsArr(1,0) = 5.0 :pntsArr(2,0) =    0.0

              pntsArr(0,1) = 5.0 :pntsArr(1,1) = -5.0 :pntsArr(2,1) =  0.0

              set usrLayGfx = docObj.PutUserLayerGfx(layerObj, 0.4, numPoints, pntsArr, False, Nothing, epcbUnitCurrent)

           

              If (Err) Then

                  Call pcbApp.Gui.StatusBarText("An error occured while creating the object: " + vbNewLine + Err.Description,epcbStatusFieldError)

                  Exit Sub

              Else

                  resultMess = "Fabrication layer element was created"

           

                  'select the object and fit it on the board

                  usrLayGfx.selected = True

                  docObj.ActiveView.SetExtentsToSelection

                  usrLayGfx.selected = False

           

                  'Update status bar

                  Call pcbApp.Gui.StatusBarText(resultMess,epcbStatusField1)

              End If

          End Sub

          • 2. Re: How to add graphics object on user draft layer
            joseph.spang1

            Hi Satoru,

             

            No way...

            See the attached complete script.

             

            Regards,

            Joseph

            • 3. Re: How to add graphics object on user draft layer
              Satoru

              Hi Joseph-san,

               

              I send two sample scripts.

              One is the script which corrected your code.

              Another is the script which put the code into the template which I'm using.

              Please refer to them.

               

              Regards,

              Satoru

              1 of 1 people found this helpful
              • 4. Re: How to add graphics object on user draft layer
                joseph.spang1

                Hi Satoru,

                 

                Thanks a lot!

                However I have another question:

                I'm trying to put filled circle with this script as explain in help but I've got some errors, could you help me

                 

                '========================================================================================================================================

                     'Check UserLayer Object
                    Set layerObj = pcbDoc.FindUserLayer("PIN1")
                    If layerObj Is Nothing Then
                        'Create UserLayer Object
                        Set layerObj =  pcbDoc.SetupParameter.PutUserLayer("PIN1")
                    End If

                    pntsArr = pcbApp.Utility.CreateCircleXYR(0, 0, 1)
                    set usrLayGfx = pcbDoc.PutUserLayerGfx(layerObj, 0.1, numPoints, pntsArr, False, Nothing, epcbUnitCurrent)



                '========================================================================================================================================

                 

                Thanks in advanced

                Regards,

                Joseph

                • 5. Re: How to add graphics object on user draft layer
                  Satoru

                  Hi Joseph-san,

                   

                  A difference is in how to use a PutUserLayerGfx method.

                  I think that the number of points is not right.

                   

                  Set usrLayGfx = pcbDoc.PutUserLayerGfx(layerObj, 0.1, UBound(pntsArr, 2) + 1, pntsArr, False, Nothing, epcbUnitCurrent)

                   

                  Regards,

                  Satoru

                  • 6. Re: How to add graphics object on user draft layer
                    joseph.spang1

                    Hi Satoru,

                     

                    I need your help again.

                    After collecting FabricationLayerGfxs, I want to copy the collection on a user layer:

                     

                    set fabColl = celDoc.FabricationLayerGfxs(epcbFabAssembly, epcbSelectAll, epcbSideTop, True)

                     

                    What should I do to copy the collection?

                     

                    Thanks

                     

                    Joseph

                    • 7. Re: How to add graphics object on user draft layer
                      Satoru

                      Hi Joseph-san,

                       

                      The sample was attached.

                      Please check.

                       

                      Regards,

                      Satoru