1 2 First Previous 16 Replies Latest reply on Feb 18, 2015 11:56 AM by thad.schultz

    Automation code to export CCZ files

      Anyone already write any code to export CCZ files in 2007.3 or later?

        • 1. Re: Automation code to export CCZ files
          Satoru

          Hi jeff,

           

          Automation can call an Export CCZ window.

          But, Automation or Automation Pro can't output the CCZ file directly.

           

          Regards,

          Satoru

          • 2. Re: Automation code to export CCZ files
            yu.yanfeng

            Normally, We can use app.Gui.ProcessCommand("File->Export->CCZ...", True) to export CCZ file, but  We don't know how to entry the name of outfile. However, By a  modfied the .upf file, We can avoid this and sucessfully ouput CCZ file.

            Yanfeng

            • 3. Re: Automation code to export CCZ files

              Thanks Yanfeng, that was the direction that I was heading in, but like you I didn't know how to name the output file.  I will take a look at the .upf file.

              • 4. Re: Automation code to export CCZ files
                yu.yanfeng

                I did this for our company. Our company don't allow expose our codes to public, even it's very simle.

                 

                In fact, There are workaround here. You may use replay file or use following dumb menthod:

                 

                1) open a sample .pcb file in expeditionpcb,output the ccz file named it.

                2) use this. upf file as a template file

                3) in your automation script, do as following:

                When doing automation action to the design, script first rename the .upf file as backup.upf, and copy the template .upf into \config

                4) now the gui.processcommand will automatically .ccz file and you rename it based on the .pcb name

                5) finnaly, delete the template upf file under \config and rename backup.upf to original name

                 

                change .upf file don't have any negative effects at all, so this trick works well.

                 

                 

                Yanfeng

                • 5. Re: Automation code to export CCZ files
                  kendall_hiles

                  Here is an example to do it automatically,  the run replay is not a supported command so if it stops working hopefully there will be a better wat to do it.

                   

                  I added to AATK and it will be in the next update under manuafacturing.

                   

                  -kendall

                  • 7. Re: Automation code to export CCZ files

                    Kendall,

                    I don't know if you have noticed this or not, but the first time I run this script, it runs with the zip option (Like it is set).  However, if I run the script again, it switches to the non zip verion and if I run it again, it is back to the zip version.  Any ideas?

                    • 8. Re: Automation code to export CCZ files
                      kendall_hiles

                      DOOOHHHH.  You hit the dreaded toggle swith, I had the same thing in another replay file,  just change the script to run it twicw and then have the script blow away the one you don't want!  Not pretty but it works!

                       

                      I really do not have a solution for the checkbox GUI's.

                       

                      -kendall

                      • 9. Re: Automation code to export CCZ files

                        I was just searching on the MUG forums and I just found that you had this issue before   Thanks for the update!

                        • 10. Re: Automation code to export CCZ files

                          I just posted a request for automation hooks for this feature on the Ideas site (https://na5.brightidea.com/ct/ct_a_view_idea.bix?i=189DA9C6).  If this is something you would like to see added, please go add your vote to this.

                          • 11. Re: Automation code to export CCZ files
                            chris_czernel

                            This code works with 2007.7 (and probably 2007.6)

                             

                            Option Explicit

                             

                            ' add any type librarys to be used.
                            Scripting.AddTypeLibrary("MGCPCB.ExpeditionPCBApplication")

                             

                            ' Get the application object
                            Dim pcbApp
                            Set pcbApp = GetObject(,"MGCPCB.ExpeditionPCBApplication")
                            'Set pcbApp = CreateObject("MGCPCB.ExpeditionPCBApplication")

                             

                            ' Get the active document
                            Dim pcbDoc
                            Set pcbDoc = pcbApp.ActiveDocument
                            Dim name
                            name = pcbDoc.Name
                            name = Left(name, (InStrRev(name, ".", -1, 1) -1))
                            MsgBox name
                            ' License the document
                            ValidateServer(pcbDoc)
                            Dim fileName
                            ' change the filename to either .ccz or .cc here
                            fileName = pcbDoc.Path + name + ".ccz"

                             

                            Dim addin, addins

                             

                            Set addins = Application.Addins

                             

                            For Each addin In addins
                                If addin.Name = "CCZ Export Addin" Then
                                    Call addin.Control.OnExecuteEx(fileName)
                                    Exit For
                                End If
                            Next

                             

                            msgbox "Done - exported file: " & vbcrlf & filename

                             

                             

                             

                            ''
                            'CreateObject("CCZXportAddin.CCZXportCtrl")
                            ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
                            'Local functions

                             


                            ' Helper fucntion for including files.
                            Function FindInWDIR(sFilename, oFSO)
                                sSeparator = ";"
                                If Scripting.IsUnix Then
                                    sSeparator = ":"
                                End If
                                arrWdirs = Split(Scripting.GetEnvVariable("WDIR"), sSeparator)
                                For I = 0 To UBound(arrWdirs)
                                    sPath = arrWdirs(I) & "/" & sFilename
                                    If FSO.FileExists(sPath) Then
                                        FindInWDIR = sPath
                                        Exit Function
                                    End If
                                Next
                                FindInWDIR = sFilename
                            End Function

                            ' Helper function for including files.
                            Sub Include(fileName)
                                 Dim fso: Set fso = CreateObject("Scripting.FileSystemObject")
                                 Dim f: Set f = fso.OpenTextFile(FindInWDIR(fileName, fso),1)
                                 Dim s: s = f.ReadAll
                                 ExecuteGlobal s
                            End Sub

                             

                            ' Server validation 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

                            • 12. Re: Automation code to export CCZ files
                              yu.yanfeng

                              Hi Chris,

                              Thank you for the tip using Addins. It really works and support any version of 2007.X after that Seting addins = Application.Addins  be changed to addins=pcbApp.Addins.

                              Yanfeng

                              • 13. Re: Automation code to export CCZ files

                                Chris,

                                Have you tried this code with 7.9 yet?  It seems to work OK, but the new progress bar only gets to 99%, even though the file is done generating.  Any ideas what needs to be done to fix this or is there a better way in 7.9?

                                • 14. Re: Automation code to export CCZ files
                                  alain.maussion

                                  HI

                                  seems good

                                  My question is how to export the CCZ from the older design without open by expedition.

                                   

                                  the solution to open by expedition is no good because is necessary ro maintain older software version, risk to migrated some data or change.

                                  best way is to have a script to convert pcb data or hkp, or ... to ccz

                                  Thanks

                                  1 2 First Previous