4 Replies Latest reply on May 18, 2011 8:55 AM by john_dube

    PutFabricationLayerGfx

    andrew.french

      Expedition 7.9.1

      C#.net

       

      I'm trying to use the  PutFabricationLayerGfx command from Expedition Automation and am having issues.  The PutFabricationLayerGfx throws the error "Could not convert argument 1 for call to PutFabricationLayerGfx."

       

      Documentation says the first argument should be "ByVal eType As EPcbFabricationType" so even if I replace my variable "fabType" with "MGCPCB.EPcbFabricationType.epcbFabAssembly" in the PutFabricationLayerGfx command I get the same error.

       

      The end result of the script is to find all the pin one markers on assembly and silkscreen layers and change them to be solid fill.  Trying to fix library translation issues and the following code is stripped down to display the issue I'm encountering.

       

       

       

       

      private void drawStuff()

       

       

      {

      MGCPCB.FabricationLayerGfxs fabGfxs = App.ExpDoc.FabricationLayerGfxs;

       

       

       

       

      foreach (MGCPCB.FabricationLayerGfx fabGfx in fabGfxs)

      {

       

       

           if (fabGfx.Geometry.Filled == false)

           {

                MGCPCB.EPcbFabricationType fabType = fabGfx.Type;

                MGCPCB.EPcbSide eSide = fabGfx.Side;

                double dGraphicsWidth = fabGfx.Geometry.get_LineDisplayWidth();

                var pointsArray = fabGfx.Geometry.PointsArray;

                int nPnts = pointsArray.Length;

                App.ExpDoc.PutFabricationLayerGfx(fabType, eSide, dGraphicsWidth, nPnts, pointsArray,true, null, MGCPCB.EPcbUnit.epcbUnitCurrent);

                fabGfx.Delete();

           }

       

      }

      }

       

        • 1. Re: PutFabricationLayerGfx
          ed_smith

          Andrew,

           

          The problem may be that PutFabricationLayerGfx returns a FabricationLayerGfx object - try assigning the result of the call to a dummy FabricationLayerGfx object.

           

          I am not certain that this is the problem but have seen similar issues when using VBScript.

           

          Regards, Ed

          • 2. Re: PutFabricationLayerGfx
            andrew.french

            Changed that line to the following and still get the "Could not convert argument 1 of call to PutFabricationLayerGfx" error.

            MGCPCB.FabricationLayerGfx test = App.ExpDoc.PutFabricationLayerGfx(fabType, eSide, dGraphicsWidth, nPnts, pointsArray, true, null, MGCPCB.EPcbUnit.epcbUnitCurrent);

             

            I also took out my first two variables and the following also crashes with "Could not convert argument 1 of call to PutFabricationLayerGfx"

            MGCPCB.FabricationLayerGfx test = App.ExpDoc.PutFabricationLayerGfx(MGCPCB.EPcbFabricationType.epcbFabAssembly, MGCPCB.EPcbSide.epcbSideTop, 0, nPnts, pointsArray, true, null, MGCPCB.EPcbUnit.epcbUnitCurrent);

             

             

            • 3. Re: PutFabricationLayerGfx
              andrew.french

              The issue was related to the pointsArray variable type and the nPnts variable.  The points array wants to be of type object and I needed to divide by 3 to get the correct number of points.  So in the end this is what works for me:

               

              private void drawStuff()

              {

              App.ExpApp.LockServer();

              MGCPCB.FabricationLayerGfxs fabGfxs = App.ExpDoc.FabricationLayerGfxs;

               

               

              foreach (MGCPCB.FabricationLayerGfx fabGfx in fabGfxs)

              {

               

              if (fabGfx.Geometry.IsCircle() == true)

              {

              MGCPCB.EPcbFabricationType fabType = fabGfx.Type;

              MGCPCB.EPcbSide eSide = fabGfx.Side;

              double dGraphicsWidth = fabGfx.Geometry.get_LineDisplayWidth();

              object pointsArray = fabGfx.Geometry.PointsArray;

              dynamic pointsArrayLength = fabGfx.Geometry.PointsArray;

              int nPnts = pointsArrayLength.Length / 3;

               

              fabGfx.Delete();

               

              App.ExpDoc.PutFabricationLayerGfx(fabType, eSide, dGraphicsWidth, nPnts, pointsArray, true);

               

               

              }

              }

              App.ExpApp.UnlockServer();

              }

               

               

              I will say that if fabGfx.Geometry.Filled = true; was valid and not read only this would have been a lot easier.

               

               

               

               

               

               

               

               

               

               

               

               

              • 4. Re: PutFabricationLayerGfx
                john_dube

                Hi Andrew,

                 

                It's true that array.Length returns the total number of items in the array, for points array that is the number of points times 3 (x,y,r).  You could use the Array type, call GetUpperBound instead of Length.  Also, you need to make sure the Geometry is closed in order to fill it.  Here is my take:

                 

                                if (fabGfx.Geometry.IsClosed())

                                {

                                    MGCPCB.EPcbFabricationType fabType = fabGfx.Type;

                                    MGCPCB.EPcbSide eSide = fabGfx.Side;

                                    double dGraphicsWidth = fabGfx.Geometry.get_LineDisplayWidth();

                                    Array pointsArray = fabGfx.Geometry.PointsArray;

                                    int nPnts = pointsArray.GetUpperBound(1) + 1;

                                    try

                                    {

                                        App.ExpDoc.PutFabricationLayerGfx(fabType, eSide, dGraphicsWidth, nPnts, pointsArray, true, fabGfx.Component, MGCPCB.EPcbUnit.epcbUnitCurrent);

                                        fabGfx.Delete();

                                    }

                                    catch (Exception ex)

                                    {

                                        string msg = "Error putting FabricationLayerGfx: ";

                                        msg += ex.ToString();

                                        System.Windows.Forms.MessageBox.Show(msg);

                                    }

                                }

                 

                John