Anyone already write any code to export CCZ files in 2007.3 or later?
Automation can call an Export CCZ window.
But, Automation or Automation Pro can't output the CCZ file directly.
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.
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.
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.
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.
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?
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.
I was just searching on the MUG forums and I just found that you had this issue before Thanks for the update!
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.
This code works with 2007.7 (and probably 2007.6)
' add any type librarys to be used.Scripting.AddTypeLibrary("MGCPCB.ExpeditionPCBApplication")
' Get the application objectDim pcbAppSet pcbApp = GetObject(,"MGCPCB.ExpeditionPCBApplication")'Set pcbApp = CreateObject("MGCPCB.ExpeditionPCBApplication")
' Get the active documentDim pcbDocSet pcbDoc = pcbApp.ActiveDocumentDim name name = pcbDoc.Namename = Left(name, (InStrRev(name, ".", -1, 1) -1))MsgBox name' License the documentValidateServer(pcbDoc)Dim fileName ' change the filename to either .ccz or .cc herefileName = 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 IfNext
msgbox "Done - exported file: " & vbcrlf & filename
' 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 = sFilenameEnd 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 sEnd Sub
' Server validation functionPrivate 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
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.
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?
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
CAMCAD can be used to create CC files. CAMCAD offers a wide variety of import formats including HKP, and any imported data can be saved to CC. CAMCAD also offers an extensive API layer plus command line support for anyone who wants to script/code some automation.
Without using CAMCAD, the only way I know how to script CC output is to open the design into Expedition, then use GUI automation or addins automation to create the CC output.
I hope this helps!
I've had your code around for some time and was finally getting around to trying it out. When you do CCZ output this way does it just use the last Export Options that were selected by the last person who did a CCZ output? Is there anyway through automation to check and uncheck certain boxes or load a scheme?
Retrieving data ...