12 Replies Latest reply on Oct 28, 2009 9:36 PM by kendall_hiles

    Part Height report

    Snap_Boy

      Hi,

       

      Is there any Easy way to generate report of "Height of parts in Board"?

       

      I am trying to generate MS-Excel report through following code

       

      Sub Get_Height()

       

          Dim serverIsLocked As Boolean

          Dim prts As MGCPCB.Parts

          Dim prt As MGCPCB.Part

         

          Set prts = pcbdoc.Parts

          prts.Sort

           

         ' Define Header

          i = 2

          Range("A1").FormulaR1C1 = "part Number"

          Range("B1").FormulaR1C1 = "No. of parts"

          Range("C1").FormulaR1C1 = "Height"

          Range("D1").FormulaR1C1 = "Underside Height"

         

             

      For Each prt In prts

         

          Range("A" & i).FormulaR1C1 = prt.Name

          Range("B" & i).FormulaR1C1 = prt.Components.Count

          Range("C" & i).FormulaR1C1 = prt.Height(epcbUnitCurrent)

          Range("D" & i).FormulaR1C1 = prt.UndersideHeight

             

          On Error Resume Next

         

          i = i + 1

       

      Next

       

      MsgBox "Done!"

      End Sub

       

      But value of "prt.Height(epcbUnitCurrent)" is shows as "-1" for all components!!  

       

      Any clue?

       

       

        • 1. Re: Part Height report
          fagrondin

          Hi,

           

          is it possible that instead of :

           

          prt.Height(epcbUnitCurrent) it is prt.get_Height(epcbUnitCurrent).

           

          and

           

          prt.UndersideHeight it is prt.get_UndersideHeight

           

          Regards

           

          Fred

          • 2. Re: Part Height report
            Snap_Boy

            I am getting an error as below

             

            Error.JPG

             

            FYI

            My expedition version is 2005.1

            • 3. Re: Part Height report
              matthias.cosaert

              There are different ways the height can be defined, one is attached to the cell (default) and the other is attatched to the part (for when the default cell height isn't correct for that specific part).

              Don't know if you can get the cell height directly trough automation but you can get them from ASCII export of cells (search for "Height") or from IDF export's emp file.

              • 4. Re: Part Height report
                Snap_Boy

                Yes, I am trying to extract height defined at Part level through automation.

                 

                I believe that extracting data from ASCII & IDF is time consuming task.... Unless you have any script to do that !

                • 5. Re: Part Height report
                  Andreas.Schaefer

                  Hi,

                   

                  I would be more correct.

                  If you want a report of the height of a part (component in Automation) you should go through all items of the PlacementOutlines Collection
                  of the componet. The height you get here from is the height of you part.

                   

                  regards, Andreas

                  • 6. Re: Part Height report
                    kendall_hiles

                    The height actually belongs to the placement outline.

                     

                    There are a few examples of the in the AATK download.  vbs/Manufacturing/POV.vbs or vbs/Manufacturing/VRML.vbs

                    http://sourceforge.net/projects/uwtoolbox/


                    Sub main()
                        Get_Height
                    End Sub

                     

                    Sub Get_Height()
                        Dim pcbApp As MGCPCB.Application
                        Dim pcbDoc As MGCPCB.Document
                        Set pcbApp = GetObject(, "MGCPCB.Application")
                        Set pcbDoc = pcbApp.ActiveDocument
                       
                        ' get a doc licence
                        retVal = licenseDoc(pcbDoc)
                        If (retVal <> 1) Then Set pcbDoc = Nothing
                        Dim prts As MGCPCB.Parts
                        Dim prt As MGCPCB.Part
                        Set prts = pcbDoc.Parts
                        prts.Sort

                        ' Define Header

                        i = 2
                        Range("A1").FormulaR1C1 = "part Number"
                        Range("B1").FormulaR1C1 = "No. of parts"
                        Range("C1").FormulaR1C1 = "Height"
                        Range("D1").FormulaR1C1 = "Underside Height"

                        For Each prt In prts

                            Range("A" & i).FormulaR1C1 = prt.Name
                            Range("B" & i).FormulaR1C1 = prt.Components.Count
                       
                            Dim comps As Components
                            Dim comp As Component
                            Dim po As PlacementOutline
                            Dim pos As PlacementOutlines
                       
                            Set comps = prt.Components

                            For Each comp In comps
                                Set pos = comp.PlacementOutlines

                                For Each po In pos
                                    Range("C" & i).FormulaR1C1 = po.Height(epcbUnitCurrent)
                                    Range("D" & i).FormulaR1C1 = po.UndersideSpace
                                Next
                            Next

                            On Error Resume Next
                            i = i + 1

                        Next

                        MsgBox "Done!"

                    End Sub

                     

                    Private Function licenseDoc(docObj As MGCPCB.Document) As Integer
                    ' =======================================================================
                    ' Retrieve a licence for the document
                    ' =======================================================================
                    On Error GoTo exit_with_error
                    Dim retState As Integer

                    Dim licenseServer As Object
                    Dim key As Long
                    Dim licenseToken As Long
                    Dim outErrMess As String

                    If (docObj Is Nothing) Then GoTo end_of_function

                    ' Ask the document for a key
                    key = docObj.Validate(0)

                    ' Get license server
                    On Error GoTo err_create_serverobj
                    Set licenseServer = CreateObject("MGCPCBAutomationLicensing.Application")
                    If (licenseServer Is Nothing) Then GoTo err_create_serverobj
                    On Error GoTo exit_with_error


                    ' Ask the license server for the license token
                    licenseToken = licenseServer.GetToken(key)


                    ' Validate the document with the license token
                    On Error GoTo err_validate
                    Dim lRetval As Long
                    lRetval = docObj.Validate(licenseToken)

                    On Error GoTo exit_with_error

                    retState = 1

                    end_of_function:
                        ' release licence server
                        Set licenseServer = Nothing
                        licenseDoc = retState

                    Exit Function

                    show_error:
                       Dim ioptions As Long
                       ioptions = vbDefaultButton1 + vbApplicationModal + vbCritical + vbOKOnly
                       MsgBox outErrMess, ioptions, "Retrieving license for document"
                       GoTo end_of_function

                    exit_with_error:
                        outErrMess = "** Error ** " + Error$
                        retState = -1
                        GoTo show_error

                    err_create_serverobj:
                       outErrMess = "** Error ** Could not create license server object"
                       retState = -2
                       GoTo show_error

                    err_validate:
                       outErrMess = "** Error ** Failed to validate document object"
                       outErrMess = outErrMess + vbCrLf + "    License token : " + Trim(Str(licenseToken))
                       outErrMess = outErrMess + vbCrLf + "    Document key  : " + Trim(Str(key))
                       retState = -3
                       GoTo show_error

                    End Function

                    • 7. Re: Part Height report
                      Snap_Boy

                       

                      That works!

                      Thanks for that!

                       

                      kendall_hiles wrote:

                       

                      The height actually belongs to the placement outline.

                       

                      There are a few examples of the in the AATK download.  vbs/Manufacturing/POV.vbs or vbs/Manufacturing/VRML.vbs

                      http://sourceforge.net/projects/uwtoolbox/


                      Sub main()
                          Get_Height
                      End Sub

                       

                      Sub Get_Height()
                          Dim pcbApp As MGCPCB.Application
                          Dim pcbDoc As MGCPCB.Document
                          Set pcbApp = GetObject(, "MGCPCB.Application")
                          Set pcbDoc = pcbApp.ActiveDocument
                         
                          ' get a doc licence
                          retVal = licenseDoc(pcbDoc)
                          If (retVal <> 1) Then Set pcbDoc = Nothing
                          Dim prts As MGCPCB.Parts
                          Dim prt As MGCPCB.Part
                          Set prts = pcbDoc.Parts
                          prts.Sort

                          ' Define Header

                          i = 2
                          Range("A1").FormulaR1C1 = "part Number"
                          Range("B1").FormulaR1C1 = "No. of parts"
                          Range("C1").FormulaR1C1 = "Height"
                          Range("D1").FormulaR1C1 = "Underside Height"

                          For Each prt In prts

                              Range("A" & i).FormulaR1C1 = prt.Name
                              Range("B" & i).FormulaR1C1 = prt.Components.Count
                         
                              Dim comps As Components
                              Dim comp As Component
                              Dim po As PlacementOutline
                              Dim pos As PlacementOutlines
                         
                              Set comps = prt.Components

                              For Each comp In comps
                                  Set pos = comp.PlacementOutlines

                                  For Each po In pos
                                      Range("C" & i).FormulaR1C1 = po.Height(epcbUnitCurrent)
                                      Range("D" & i).FormulaR1C1 = po.UndersideSpace
                                  Next
                              Next

                              On Error Resume Next
                              i = i + 1

                          Next

                          MsgBox "Done!"

                      End Sub

                       

                      Private Function licenseDoc(docObj As MGCPCB.Document) As Integer
                      ' =======================================================================
                      ' Retrieve a licence for the document
                      ' =======================================================================
                      On Error GoTo exit_with_error
                      Dim retState As Integer

                      Dim licenseServer As Object
                      Dim key As Long
                      Dim licenseToken As Long
                      Dim outErrMess As String

                      If (docObj Is Nothing) Then GoTo end_of_function

                      ' Ask the document for a key
                      key = docObj.Validate(0)

                      ' Get license server
                      On Error GoTo err_create_serverobj
                      Set licenseServer = CreateObject("MGCPCBAutomationLicensing.Application")
                      If (licenseServer Is Nothing) Then GoTo err_create_serverobj
                      On Error GoTo exit_with_error


                      ' Ask the license server for the license token
                      licenseToken = licenseServer.GetToken(key)


                      ' Validate the document with the license token
                      On Error GoTo err_validate
                      Dim lRetval As Long
                      lRetval = docObj.Validate(licenseToken)

                      On Error GoTo exit_with_error

                      retState = 1

                      end_of_function:
                          ' release licence server
                          Set licenseServer = Nothing
                          licenseDoc = retState

                      Exit Function

                      show_error:
                         Dim ioptions As Long
                         ioptions = vbDefaultButton1 + vbApplicationModal + vbCritical + vbOKOnly
                         MsgBox outErrMess, ioptions, "Retrieving license for document"
                         GoTo end_of_function

                      exit_with_error:
                          outErrMess = "** Error ** " + Error$
                          retState = -1
                          GoTo show_error

                      err_create_serverobj:
                         outErrMess = "** Error ** Could not create license server object"
                         retState = -2
                         GoTo show_error

                      err_validate:
                         outErrMess = "** Error ** Failed to validate document object"
                         outErrMess = outErrMess + vbCrLf + "    License token : " + Trim(Str(licenseToken))
                         outErrMess = outErrMess + vbCrLf + "    Document key  : " + Trim(Str(key))
                         retState = -3
                         GoTo show_error

                      End Function

                       

                       

                      Thank you all!

                      • 8. Re: Part Height report
                        Guru

                        Is there any way I can report the Assembly/Silkscreen elements, Number of placement outlines etc for all cells in a central library

                        by using the celleditor data model similarly? I can get the Height, Pincount, Number of layers etc using the Cell editor objects but

                        couldnt find a way to report the others..

                        • 9. Re: Part Height report
                          Snap_Boy

                           

                          'FabricationLayerGfxs' & 'FabricationLayerTexts' may can help you!

                          • 10. Re: Part Height report
                            Guru

                            But using 'FabricationLayerGfxs' & 'FabricationLayerTexts' I can report only cells used in a design right? I want to report all the cells available

                            in a Central Library Cell database (Library manager cell Editor) .. not through Expedition PCB..

                            • 11. Re: Part Height report
                              kendall_hiles

                              This is the latest from AATK.

                               

                              Opens a new Excel and adds the heights.  Just drag and drop onto Expedition (Windows)  use the keyin run <path> from Linux/Solaris

                              • 12. Re: Part Height report
                                kendall_hiles

                                In .5 on the CL has Automation.  I have not got into it very much but it may be doable on the lib now.