8 Replies Latest reply on May 21, 2014 3:12 PM by k-brady1

    How can I retrieve the refdes property on a cell??


      We have Expedition libraries that were created by using the BoardStation to Expedition translator and we have some incorrect values for the refdes property.  I want to process all cells in every partition of the library and retrieve the value for the RefDes property and if it is not $$_^$REF then I simply want to log the partition/cell name to a file for review.  Documentation for the cell editor states that the property is RefDes.  I have tried to use FindProperty("RefDes") and FindProperty("Ref Des") and both return null.  

        • 1. Re: How can I retrieve the refdes property on a cell??

          Yep, we had similar issues and had to do a lot of clean up after the translation as well.  We ended up just shelving that library and picking parts from it as needed.  I write my code in C# so you may need to do some conversions of your own but this should get you going in the right direction.  the assembly and silkscreen items are fabrication items and you can target them more specifically if need be.


          private void button1_Click(object sender, EventArgs e)


                      string lib = label1.Text;



                      if (lib == "Select a Library")


                          MessageBox.Show(this, "You must select a library(lmc) file before proceeding!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);





                      //Create handle to the cell editor using the library specified in the global variables section

                      CellEditorAddinLib.CellEditorDlg cellEd = new CellEditorAddinLib.CellEditorDlg();

                      CellEditorAddinLib.CellDB cellDB = cellEd.OpenDatabase(lib, false);



                      //Get the collection of partitions in the library and iterate through them

                      CellEditorAddinLib.Partitions partitions = cellDB.get_Partitions();

                      foreach (CellEditorAddinLib.Partition p in partitions)


                          //Get the collection of cells in the current partition and iterate through them

                          CellEditorAddinLib.Cells cells = p.get_Cells();

                          foreach (CellEditorAddinLib.Cell c in cells)




                              //Open the current cell with the Cell Editor and create a handle to it

                              MGCPCB.Document ExpDoc = c.Edit();

                              MGCPCB.Application ExpApp = (MGCPCB.Application)ExpDoc.Application;

                              MGCPCB.EPcbUnit unit = ExpDoc.CurrentUnit;



                              //Lock the server for better performance




                              //Make all cell edits here


                              MGCPCB.FabricationLayerTexts txts = ExpDoc.get_FabricationLayerTexts();



                              foreach (MGCPCB.FabricationLayerText txt in txts)



          //Make your Cell edits here





                              //Release handle on cell editor


                              ExpDoc.Close(true);  //saves cell

                              ExpDoc = null;

                              ExpApp = null;



                          } //cells

                      } //partitions



                      //Save and exit out of the Library and release handles



                      cellEd = null;

                      cellDB = null;




                      //log = null;



          • 2. Re: How can I retrieve the refdes property on a cell??

            where it says //Make Cell Edits here


            To determine if the item is a refdes you'll need to add

            if(txt.TextType == MGCPCB.EPcbTextType.epcbTextRefDes)


            //do something


            • 3. Re: How can I retrieve the refdes property on a cell??

              Hi Andrew,


              Thank you very much for the assistance!!  I will test this and let you


              • 4. Re: How can I retrieve the refdes property on a cell??

                Hi Andrew,


                I have successfully implemented/tested your code.  I'm still a little

                confused about this...  I had understood from the documentation that there

                should be a property RefDes in the cell and obviously this is not the case.

                I had code that looped thru all properties on each cell but it was only

                User properties.  How did you figure out that this data was stored in the

                FabricationLayerText??  Also, is it the text "Ref Des" that is significant

                or the use of $$_^$REF which I assumed replaced with the reference

                designator text on an instance in a board??  Again, thank you so much for

                your help!!

                • 5. Re: How can I retrieve the refdes property on a cell??

                  I guess I am confused at what you are looking for.  The only place the ref des will appear on a cell in the cell editor is on the silkscreen and/or assembly layers.  In the cell editor, this will appear literally as the text "Ref Des"


                  It sounds like to me you're looking for the ref des prefix in the part editor? I've never seen $$_^REF before.  Where are you seeing this?

                  • 6. Re: How can I retrieve the refdes property on a cell??

                    HI Andrew,


                    If I use CellDB2HKP, the error condition that I'm trying to trap is the

                    following error condition for the assembly/silkscreen reference designator.

                    This situation occurs if someone forgets to run a clean-up utility on the

                    cells that are being translated from BoardStation.

                    ..TEXT "$$_^$REF"

                      ...TEXT_TYPE REF_DES



                    ..TEXT "Ref Des"

                      ...TEXT_TYPE REF_DES


                    I need to identify cells that have the Text "$$_^$REF" vs "Ref Des".  If I

                    retrieve txt.TextString I am getting "Ref Des" vs. $$_^$REF.


                    So the code looks like:


                    • 7. Re: How can I retrieve the refdes property on a cell??

                      Hi Andrew,


                      It appears that the cell editor is correcting this data which explains why

                      I can't detect the bad value.  Our librarian saw the bad value using

                      preview.  If I preview the cell in library manager I see the text $$_^$REF.

                      Now if I open the cell in the cell editor and do nothing other than save

                      it, this text has changed from $$_^$REF to Ref Des so as part of opening

                      the cell in the cell editor this data item was updated.  I will get with

                      our librarians to determine if there is another data item that persists in

                      the cell editor that we can use to detect when the cells have not been

                      processed with the clean-up script.  Thank you so much for all of your help

                      with this!!

                      • 8. Re: How can I retrieve the refdes property on a cell??

                        Hi Andrew,


                        Our process is to run the translator and then a clean-up script on the

                        cells.  One of our librarians noticed some strange text for the reference

                        designator in the cell preview window, i.e. $$_^$REF.  This text would

                        normally be corrected by the clean-up script but apparently some cells were

                        loaded into the library before the script was run so I wanted to write a

                        utility to identify these cells.  In reviewing the clean-up script, it was

                        responsible for generating the silkscreen reference designator so instead

                        of looking for this translator value as the text field content I have

                        changed the code to identify cells that did not have a SilkScreen Reference

                        Designator.  Originally the code was testing for a fabrication layer text

                        item value of $$_^$REF without success even though this value was displayed

                        in the preview window.  The cell editor must automatically change the value

                        of $$_^$REF to Ref Des.  After much confusion I determined that if I opened

                        the cell in the cell editor (required by the automation) and did nothing to

                        the cell other than save it, that the value of $$_^$REF had been changed to

                        Ref Des.  I have no idea why the cell editor is automatically making this

                        update to the cell.  So I have resolved my issue and thank you again for

                        your help.