4 Replies Latest reply on Feb 8, 2011 8:00 AM by jens.radeloff

    Copy Component Placement Outline to AssemblyLayer

    jens.radeloff

      Hi,

       

      I just do some first steps in programming MentorExpedition Automation with DotNet (VisualBasicExpress Edition). My Task is to copy the component placement outline to the fabrication Layer AssemblyTop. My problem is an type missmatch error when I call the function "PutFabricationLayerGfx". In my opinion where is a problem with the array but I have no idea which kind of.

       

      The error message says: "Typconflict. (Exception of HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))"

       

      And here is my code extraction:

      For Each component In PCBDoc.components

           Try

                 Dim geomObj

                 Dim Arr

                 Dim ArrLen As Integer

                 Dim fabGfxObj

       

                For Each PO As MGCPCB.PlacementOutline In component.placementoutlines

       

                     If PO.IsValid Then

                          If PO.Height = 0 Then

                               geomObj = PO.Geometry

                               Arr = geomObj.pointsArray

                               ArrLen = UBound(Arr, 2) + 1

                              

                               fabGfxObj = PCBDoc.PutFabricationLayerGfx(MGCPCB.EPcbFabricationType.epcbFabAssembly, _

                                                                                                     MGCPCB.EPcbSide.epcbSideTop, 4.0, ArrLen, Arr, _

                                                                                                      False, Nothing, MGCPCB.EPcbUnit.epcbUnitCurrent)

       

                          End If

                      End If

                 Next

       

           Catch ex As Exception

                MsgBox(ex.Message)

           End Try

       

      Next

       

      Can everyone help me? Thanks a lot!!

       

      Greetings,

      Jens

        • 1. Re: Copy Component Placement Outline to AssemblyLayer
          matthias.cosaert

          Hi,

           

          You have to use 'set Var = Obj' when collecting objects (geomObj & fabGfxObj)

           

          Greetings,

          Matthias

          • 2. Re: Copy Component Placement Outline to AssemblyLayer
            jens.radeloff

            Hi,

             

            with DotNet (Visual Basic Express; not VBScript) it is not neccessary to say SET. During programming in Visual Basic SET will be automatically deleted...

            • 3. Re: Copy Component Placement Outline to AssemblyLayer
              matthias.cosaert

              [edit]

               

              I only use vbs so I'm not falimiar with vb.net but I checked the vb6 examples  (%SDD_HOME%\standard\examples\pcb\Automation\VisualBasic6)

              and it seems you also have to say it's an object when you declare the variable (That's probably why the set got deleted):

               

              Dim geomObj As object
              Dim fabGfxObj As object

              • 4. Re: Copy Component Placement Outline to AssemblyLayer
                jens.radeloff

                Hi,

                obviously there seems to be differences between vb6 and dotNet. Within DotNet you don't have to use SET. It doesn't matter which kind of variable you deal with.

                But in the meantime I looked into the function description. Within Visual Basic Express Edition you can find an Object Catalog. Within the package "MGCPCB" you can find the function "PutFabricationLayerGfx". The function is descripted as follow:

                 

                Public Overridable Function PutFabricationLayerGfx(ByVal eType As MGCPCB.EPcbFabricationType, ByVal eSide As MGCPCB.EPcbSide, ByVal dGraphicsWidth As Double, ByVal nPnts As Integer, ByRef safeArrayOfPnts As Object, Optional ByVal bFilled As Boolean = False, Optional ByVal pComponent As MGCPCB.Component = Nothing, Optional ByVal eUnit As MGCPCB.EPcbUnit = epcbUnitCurrent)

                 

                Very interesting is the definition of safeArrayOfPnts. There you can find the keyword ByRef. This means that the function puts data to this variable. I'm confused. I thought that you put an array of data with the geometry to the variable and the function will draw this geometry to the fabrication layer. What does this mean???