4 Replies Latest reply on Nov 17, 2017 7:19 AM by peter_festesen

    Usage of the PutFabricationLayerTextOnLayer method in Cell Editor 

    peter_festesen

      Hi - does anyone here have experience with the

      PutFabricationLayerTextOnLayer method.

       

      Our intention is to use it to add a property to a existing user layer in the cell in Cell Editor.  Our expectation is to mimic the  Cell Editor 'Draw-Property Text' feature to add a number of properties to a user draft layer

      Documentation says:

      Function PutFabricationLayerTextOnLayer(sString As String, PositionX As Double, PositionY As Double, eTextType As EPcbTextType, eType As EPcbFabricationType, eSide As EPcbSide, [pLayerObject As LayerObject], [pComponent As Component], [eUnit As EPcbUnit = epcbUnitCurrent]) As FabricationLayerText

       

      where

      pLayer - parameter is only used for flex designs and soldermask text (which we are not using) . We have tried omitting, setting it to the appropriate layer object and also tried 'Nothing as the object.

      pComponent - must be sepcified. As thgis is cell editor, we use 'Nothing' as the component object

       

      In order to avoid trouble regarding enumerated types, we use the numbers instead. Both the propety 'Tolerance' and the NewPF User Draft layer do exist.

       

      The key code :

      For each objUserLayer in objActiveDoc.UserLayers

           If objUserLayer.Name = "NewPF" Then

                Set objLayer=objUserLayer

                MsgBox objLayer.Name & " found, trying to add property"

           End if

      Next

      'epcbTextPartProperty = 64

      'epcbFabAssembly = 1

      'epcbSideMount = 513

       

      Set strLayerText = objActiveDoc.PutFabricationLayerTextOnLayer("Tolerance",0,0,64,1,513,Nothing,Nothing,0)

       

      The last line fails with 'Invalid Parameters'

       

      If we use

      Set strLayerText = objActiveDoc.PutFabricationLayerTextOnLayer("Tolerance",0,0,64,1,513,objLayer,Nothing,0)

       

      gives us 'Type Mismatch error

       

      Any hints that help us move forward are highly appreciated.

        • 1. Re: Usage of the PutFabricationLayerTextOnLayer method in Cell Editor 
          matthias.cosaert

          Hi,
          The objActiveDoc.userlayers return userlayer objects, you'll have to use the Application.Utility.NewLayerObject()  to create a layer object.


          Havn't tested it yet but should be someting like this:

           

           

            If objUserLayer.Name = "NewPF" Then

                Set objLayer = Application.Utility.NewLayerObject()

               set objLayer.userlayer = objUserLayer

               MsgBox objLayer.userlayer.Name & " found, trying to add property"

           

          End if

           

           


          • 2. Re: Usage of the PutFabricationLayerTextOnLayer method in Cell Editor 
            peter_festesen

            Hi Mathias - thanks for your input .

             

            But the User Draft Layer 'NewPF' does already exist.

             

            I tried this instead, same result....

             

            For each objUserLayer in objActiveDoc.UserLayers

                 If objUserLayer.Name = "NewPF" Then

                      MsgBox objUserLayer.Name & " found, trying to add property"

                      Set strLayerText = objActiveDoc.PutFabricationLayerTextOnLayer("Tolerance",0,0,64,1,513,objUserLayer,Nothing,0)

                 End if

            Next

            • 3. Re: Usage of the PutFabricationLayerTextOnLayer method in Cell Editor 
              matthias.cosaert

              Hi,
              The LayerObject is only used to pass to the PutFabricationLayerTextOnLayer call but I just saw in the documentation that it is only used for flex designs and soldermask text so that wasn't the issue.

               

              To place a part property on a userlayer you need to use the PutuserlayerTextEx method:

              Scripting.AddTypeLibrary("MGCPCB.ExpeditionPCBApplication")

              set objActiveDoc = application.ActiveDocument

              For each objUserLayer in objActiveDoc.UserLayers
                   If objUserLayer.Name = "NewPF" Then

                        set ObjLayer = objUserLayer

                        MsgBox objLayer.Name & " found, trying to add property"

                   End if

              Next

              Set strLayerText = objActiveDoc.PutUserLayerTextEx("NewPF",0,0,epcbTextPartProperty   ,ObjLayer  ,Nothing,epcbUnitCurrent )

               

              1 of 1 people found this helpful
              • 4. Re: Usage of the PutFabricationLayerTextOnLayer method in Cell Editor 
                peter_festesen

                Mathias - you made my day !!! 
                I omitted some of the code (no need to go via objLayer), so I am now using

                 

                For each objUserLayer in objActiveDoc.UserLayers

                     MsgBox objUserLayer.Name & " found..."

                     If objUserLayer.Name = "NewPF" Then

                          MsgBox objUserLayer.Name & " found, trying to add property"

                          Set strLayerText = objActiveDoc.PutUserLayerTextEx("Tolerance",0,0,epcbTextPartProperty,ObjUserLayer,Nothing,epcbUnitCurrent)

                     End if

                Next


                And it works like a charm !!!!