7 Replies Latest reply on Nov 20, 2009 5:02 AM by bob.pettigrew

    Automation Pro Batch engines - outputing GeneralInterfaceEngines GenCad

    bob.pettigrew

      I'm having a problem writing a script to automate the GenCad option for the GeneralInterfaceEngines.

      Below is the main subroutine of the script indicating the error's.

       

      Sub RunGenCad()

       

      Dim GeneralInterfaceEngine

      Dim eengGenIntPartNumber

      Dim eengGenIntOutputGenCad

       

      Set GeneralInterfaceEngine = CreateObject("MGCPCBEngines.GeneralInterfaceEngine")

       

      GeneralInterfaceEngine.DesignFileName = JobName

      GeneralInterfaceEngine.OutputDir = JobConfigPath

       

      ***error   GeneralInterfaceEngine.IdentifyPartBy = eengGenIntPartNumber

      ***error   GeneralInterfaceEngine.OutputType = eengGenIntOutputGenCad

       

      ***error massage is "An event was unable to invoke any of the subscribers"

       

      GeneralInterfaceEngine.go

       

      End Sub

       

      Any help would be appreciated.

       

      Bob Pettigrew

      Gentex Corp.

        • 1. Re: Automation Pro Batch engines - outputing GeneralInterfaceEngines GenCad
          al_layson

          Bob,

          You need to include the following line to add the type library for the GeneralInterfaceEngine. This contains the definitions/values for the enums you are trying to use (eengGenIntPartNumber & eengGenIntOutputGenCad).

           

               Scripting.AddTypeLibrary ("MGCPCBEngines.GeneralInterfaceEngine")

           

          You also need to remove their Dim declarations since they are enums supplied by the type library.

               'Dim eengGenIntPartNumber

               'Dim eengGenIntOutputGenCad

          Regards,

          Al

          • 2. Re: Automation Pro Batch engines - outputing GeneralInterfaceEngines GenCad
            bob.pettigrew

            Al,

             

            Thanks for the info.

             

            When I add the scripting type library, I get an error "Object required: 'Scripting'.

             

            Any suggestions.

             

            Robert

            • 3. Re: Automation Pro Batch engines - outputing GeneralInterfaceEngines GenCad
              al_layson

              Bob,

              If you're trying to execute the script externally (IE from desktop), you need to use mgcscript to execute your script. If executing inside of expedition it's not needed. Check out info on mgcscript in documentation.

              Al

              • 4. Re: Automation Pro Batch engines - outputing GeneralInterfaceEngines GenCad
                bob.pettigrew

                Yes, I'm running the script from inside of Expedition. Still not sure what my original problem is.

                I attended script training in Longmont Colorado in August. So I'm new to this stuff. I will keep tying.

                 

                Thanks,

                Robert

                • 5. Re: Automation Pro Batch engines - outputing GeneralInterfaceEngines GenCad
                  bob.pettigrew

                  Al,

                   

                  Just got the script to working with your help. By removing the Dim statements and adding a const for the eegnGenIntOutputGenCad,

                  it now seems to work. I did not need the ScriptTypeLib like you said.

                   

                  Thanks,

                  Robert

                  • 6. Re: Automation Pro Batch engines - outputing GeneralInterfaceEngines GenCad
                    al_layson

                    Bob,

                    Below is a working script to generate GenCad and shows the way that you should code using enums. The problem with not using the constants (ENUMs) provided in a release is that the values may change from release to release, making your code incompatible between releases. For example, today the value for eengGenIntOutputGenCad = 4. If you defined a constant or variable in your code to an explicit 4 and use it in the GeneralInterfaceEngine.OutputType parameter, it will work, akin to saying GeneralInterfaceEngine.OutputType=4. However, if in future releases the enum eengGenIntOutputGenCad, as supplied by the scripting library "MGCPCBEngines.GeneralInterfaceEngine", is changed to 6 - and the engine changed accordingly, your code will no longer work. Your code will be trying to set it to 4 and the engine is now referred to by 6. Whereas, if you used the enum "eengGenIntOutputGenCad", you don't have to worry about it - and there are a lot of enums to use in automation!

                     

                     

                    Option Explicit

                    Dim pcbApp
                    Set pcbApp = GetObject(,"MGCPCB.ExpeditionPCBApplication")
                    Scripting.AddTypeLibrary("MGCPCB.ExpeditionPCBApplication")
                    Scripting.AddTypeLibrary ("MGCPCBEngines.GeneralInterfaceEngine")

                    ' Get the active document
                    Dim pcbDoc
                    Set pcbDoc = pcbApp.ActiveDocument

                    'main function of this script
                    Sub RunGenCad()
                    Dim GeneralInterfaceEngine
                    Set GeneralInterfaceEngine = CreateObject("MGCPCBEngines.GeneralInterfaceEngine")
                    GeneralInterfaceEngine.DesignFileName = pcbDoc.Path + pcbDoc.Name
                    GeneralInterfaceEngine.OutputDir = pcbDoc.Path + "Output"
                    GeneralInterfaceEngine.IdentifyPartBy = eengGenIntPartNumber
                    GeneralInterfaceEngine.OutputType = eengGenIntOutputGenCad
                      GeneralInterfaceEngine.go
                    End Sub

                     

                    ' License the document and call main
                    If (ValidateServer(pcbDoc) = 1) Then Call RunGenCad()

                    '---------------------------------------
                    ' Begin Validate Server Function
                    '---------------------------------------
                    Private Function ValidateServer(doc) 
                        Dim key, licenseServer, licenseToken
                        ' Ask Expedition’s document for the key
                        key = doc.Validate(0)
                        ' Get license server
                        Set licenseServer = CreateObject("MGCPCBAutomationLicensing.Application")
                        ' Ask the license server for the license token
                        licenseToken = licenseServer.GetToken(key)
                        ' Release license server
                        Set licenseServer = Nothing
                        ' Turn off error messages.  Validate may fail if the token is incorrect
                        On Error Resume Next
                        Err.Clear
                        ' Ask the document to validate the license token
                        doc.Validate(licenseToken)
                        If Err Then
                            ValidateServer = 0   
                        Else
                            ValidateServer = 1
                        End If
                    End Function
                    '---------------------------------------
                    ' End Validate Server Function
                    '---------------------------------------

                     

                    Regards,

                    Al

                    • 7. Re: Automation Pro Batch engines - outputing GeneralInterfaceEngines GenCad
                      bob.pettigrew

                      Al,

                       

                      Thanks for the example code and your help with this.

                       

                      Robert