2 Replies Latest reply on May 31, 2017 9:33 PM by navita@rafael.co.il

    Extracting cell information from a user layer




      I need to extract an outline dimension of a geometry defined for a cell in a user layer.

      You can see (in the attached pictures) that the information is defined under user draft layers -> Thermal outline.


      I was able to get to this information using automation but only when the Graphic editor of the cell editor was open on a specific cell.

      I need to fully automate this process. I can do it in 2 different flows:

      1. Extract all cells information stored in the LMC with required information. 

      2. For a specific open design in the xPCB extract this information for the cells in the design.

      I encounter a problem reching this information when doing it not from the graphic editor

      For each flow, i wrote the code that get to the cells information, but I couldn't find a way to get to the geom.otline information.

      See code examples.



      //Test with LMC and cell editor graphic open for a specif cell - This  works! missing full automation

      MGCPCB.CellEditorApplication cellApplication =


      MGCPCB.Document doc = cellApplication.ActiveDocument;


      //Check UserLayer Object

      MGCPCB.UserLayer layerObj = doc.FindUserLayer("THERMAL OUTLINE");

      MGCPCB.IMGCPCBUserLayerGfxs layerGraphic = doc.UserLayerGfxs;//(epcbSelectAll, "THERMAL OUTLINE", False);

      Dictionary<string, object> cells = new Dictionary<string, object>();


      foreach (MGCPCB.UserLayerGfx item in layerGraphic)


                    item.Selected = true;

                     item.Highlighted = true;

                    MGCPCB.Dimensions d = item.Dimensions;

                    MGCPCB.IMGCPCBProperties Layerprops = item.Properties;



                     Dictionary<string, string> props = new Dictionary<string, string>();

                   foreach (MGCPCB.Property item2 in Layerprops)


                       props.Add(item2.Name, item2.Value);




                    MGCPCB.Geometry geom = item.Geometry;

                      MGCPCB.EPcbShapeAttr attr = geom.Attributes;

                    var geomOut = geom.Outline; ------------------------------> This is what I need



      See code example from xPCB - can't get to the information i need

      //Test with xPCB

                  MGCPCB.Application app = (MGCPCB.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("MGCPCB.Application");

                  MGCPCB.Document doc = app.ActiveDocument;



                  //Get all layout cells

                  MGCPCB.Cells docCells = doc.Cells;

                  Dictionary<string, MGCPCB.Cell> celldic = new Dictionary<string, MGCPCB.Cell>();

                  foreach (MGCPCB.Cell c in docCells)


                      celldic.Add(c.Name, c);



                  CellEditorDlg celleditor = doc.CellEditor;

                  CellDB db = celleditor.ActiveDatabase;

                  CellEditorAddinLib.Partitions pars = db.Partitions;

                  Dictionary<string, object> pcbCurrentcells = new Dictionary<string, object>();

                  List<string> paratitionName = new List<string>();


                  foreach (CellEditorAddinLib.Partition item in pars)



                      Cells paratitionCells = item.Cells;

                      foreach (Cell c in paratitionCells)


                          pcbCurrentcells.Add(c.Name, c);  -----------------------------> When examining the cell object it doesn't contain this information






      Any help will be appreciated


        • 1. Re: Extracting cell information from a user layer

          The result of the following will be a dictionary filled with the THERMAL OUTLINE geometries of every cell in a PCB design:


          (assumes you already have a global reference to doc, from another routine that connects to the open PCB session.)


               Sub get_cell_data()


                   Dim comps As MGCPCB.Components

                   Dim comp As MGCPCB.Component

                   Dim cell_geoms As New Dictionary(Of String, MGCPCB.Geometry)

                   Dim geom As MGCPCB.Geometry




                   comps = doc.Components(0)

                   For Each comp In comps

                       If Not cell_geoms.ContainsKey(comp.Cell.Name) Then

                           geom = get_thermal_outline(comp)

                           cell_geoms.Add(comp.Cell.Name, geom)

                       End If



               End Sub




               Public Function get_thermal_outline(comp As MGCPCB.Component) As MGCPCB.Geometry


                   Dim ulgfxs As MGCPCB.UserLayerGfxs

                   Dim ulgfx As MGCPCB.UserLayerGfx


                   ulgfxs = comp.UserLayerGfxs

                   For Each ulgfx In ulgfxs

                       If ulgfx.UserLayer.Name = "THERMAL OUTLINE" Then

                           geom = ulgfx.Geometry

                           Return geom

                       End If



               End Function



          This assumes that the Thermal Outline will be a single closed loop drawn object.  If it's many smaller objects, the code would need to be changed to work with many geometries, and combine them. 

          1 of 1 people found this helpful
          • 2. Re: Extracting cell information from a user layer

            Patrick, Thank you,

            This is exactly what I needed.