5 Replies Latest reply on Apr 23, 2014 11:08 PM by renjith.varughese

    Finding a Cell in the design


      Hello All.



      In my script I want to look for a cell by using



         Set DrawingCellobj = pcbDoc.Findcell(Dwg)                                                                                                                                                                            ' Look for the drawing cell

               If (DrawingCellObj is nothing) then                                                                                                                                                                                     ' If not found

                   msgbox (Dwg & " Not Found in Design. Use Library Services to Load it !!!!!")                                                                                                                     ' Warn user for missing Cell and exit


              Set CompsCol = DrawingCellObj.components                                                                                                                                                                     ' Get the component that the cell is attached to                  

              If (CompsCol.count = 0) Then                                                                                                                                                                                             ' If not attached to any

                  Call pcbDoc.PutComponent(Dwg, False, FrameX, FrameY, 0,,,1,False,epcbAnchorNone,epcbunitmm,epcbAngleUnitDegrees)                                               ' Place the drawing cell on the design






      The problem is that it will not find mechanical/drawing cells that have never been placed on the board.


      Is there a solution for this issue



      regards, Charles

        • 1. Re: Finding a Cell in the design


          The description of the FindCell method is documented as "Finds a cell with the specified name that the document contains.". In other words a cell that is placed on the board. It does not find cells in the local library. Maybe you want to use the Document.Cellnames property instead.


          • 2. Re: Finding a Cell in the design

            Hi All,


            Found a way to look for a specific cell, placed or not.



            ' Function that looks for a cell with the cell editor and returns true when found

            function FindCell(Cell_Name)


                dim CellEditor

                dim PDB

                dim ActivePartition

                dim cell


                set CellEditor = pcbDoc.CellEditor                                                                                              ' Get a reference to the cell editor

                CellEditor.visible = false                                                                                                             ' Turn visibility off  

                set PDB = Celleditor.ActiveDatabase                                                                                           ' Get a reference to the cell partition

                set ActivePartition = PDB.activePartition                                                                                     ' And make the partition active


                for each Cell in ActivePartition.cells                                                                                           ' Search the partition

                    if Cell.Name = Cell_Name then                                                                                              ' And when cell is found

                        FindCell=true                                                                                                                   ' Return true

                    end if



            end Function

            • 3. Re: Finding a Cell in the design



              Can we di this in Expedition application itself, instead of CellEditor?




              • 4. Re: Finding a Cell in the design



                you run this script inside ExpeditionPCB.


                By calling the script you can get the information about a specific cell in the design.



                regards, Charles

                • 5. Re: Finding a Cell in the design

                  Hello Charles,


                  Thanks for the quick reply,


                  If we add a function like below. Do you see any problem?


                  Dim pcbAppObj
                  Set pcbAppObj =CreateObject("MGCPCB.ExpeditionPCBApplication")
                  ' Get the active document
                  Dim pcbDocObj
                  Set pcbDocObj = pcbAppObj.ActiveDocument
                  Dim cell
                  Foreach Cellin pcbDocObj.Cells                                                                                          
                      If Cell.Name = Cell_Namethen