I see from the Blogs that a number of people have started new projects which read and parse .hkp files. Help me to understand why you would choose to read an .hkp file when the use of Automation would seem to be easier and offer so many other advantages (such as speed of development, speed of execution and ease of integration into the application). Everything (and more) that is in an .hkp file is available through Automation.
I have done both - I've picked information out of .hkp files and I've used Automation and I wouldn't want to go back to reading .hkp files.
Does Automation have the perception of having a steep learning curve? Is it just that it's easier to work with what you already know? Is Automation deficient in some respect?
I would find it instructive to understand why, when undertaking a new project, you would rather read an .hkp file than use Automation. Any feedback will be appreciated.
Thanks, Ed
For me, I use both .HKPs and Automation. Automation is good and easy to use, there is no long-learn curve there,but have limited API and seems not so stable. Sometime I what things be done without Expeditionpcb GUI, so I turn to .HKPs. Sometime may pepople prefer the openss of HKPs just loving freedom^_^
Yanfeng
First reason is that we are still on 2005 and as library design is concerned it's better to stay on it for at least a year. Second, as mentioned above, is that automation API is not providing all the functionality of HKP (yet). I haven't used automation but I support the idea of providing users with access to CAD's internal functions. But at the same time there must be an export to human-readable format and it must export everything (it may be new XML-based format as extending current HKP format may be tricky, and this new format must be documented). Many things are easier, faster and better to do by processing text files, not by using automation.
Thank you both for replying - I hope to pick up some additional comments in time.
If you are both on 2005 then you are correct not everything that can be extracted from .hkp is available in Automation. If we are talking about 2007.3+ then I am hard pressed to think of something that's not available in Automation.
A comment was made about the stability of Automation: It's our experience that it is very stable - we are huge consumers of Automation so we tend to shake out all the issues internally. I won't say there are zero defects but there are very few. If you discover an Automation defect I would encourage you to submit it - we work very aggressively to fix these defects.
Thanks, Ed
Hi Smith,
We use 2007.2. When I wanna output a DXF file from Expeditionpcb, I can't find how to control which items to output using API, I have to use a reply file, and it's not so stable.
Yanfeng
Option Explicit
' Get the application object
Dim pcbApp
Set pcbApp = GetObject(,"MGCPCB.Application")
' Get the active document
Dim pcbDoc
Set pcbDoc = pcbApp.ActiveDocument
' License the document
ValidateServer(pcbDoc)
pcbApp.Gui.SuppressTrivialDialogs=true
' add a reference to the MGCPCB type library in order to use enums
Scripting.AddTypeLibrary("MGCPCB.Application")
' Invoke Idf Import dialog
pcbApp.Gui.ProcessCommand("File->Export->DXF...")
' Get a reference to this dialog
dim dlgObj
Set dlgObj = pcbApp.Gui.FindDialog("General Interfaces")
' Create a replay file to fill out the controls in the form.
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
Dim file
Set file = fso.CreateTextFile("C:\Temp\FillDXF.l", True)
file.WriteLine("* Version 1.0: ")
file.WriteLine("c 0 32937")
file.WriteLine("c 0 32697")
file.WriteLine("n 0 16 102 0 1008 c Local: ZTEFabDataOutDXF_MM")
file.WriteLine("n 0 16 102 0 1 b 8")
file.WriteLine("a 0 1")
file.WriteLine("e 0 0 <22202567,220885370> 0 0 36592")
pcbDoc.ReplayFile("C:\Temp\FillDXF.l")
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Local functions
Private Function ValidateServer(doc)
dim key, licenseServer, licenseToken
' Ask Expedition 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
I see you are using the hidden, undocumented and unsupported, ReplayFile method on the document. There is a reason that it's hidden - it's designed for internal use, not for general use. :-)
If you want to drive the General Interfaces dialog there is an engine available in Automation Pro.
Regards, Ed
Yes, I used the undocumented menthod to control what items be outputed. I know there is the engines, but the difficulty is that we don't know how to control items be ouputed.
The methods on the General Interfaces object are described in the Automation Help document. Let me know if that is not sufficient and I will see if I can find you some additional information.
Regards, Ed
Hello everybody,
I found this interesting thread and I have the same requirement like Yu Yanfeng: Export DXF with Automation.
So I took a look on the automation documentation in EE2007.5. In one point you're right meanwhile there are more export engines available through automation than in EE2005, but DXF export is still missing. Or better said: I was not able to find anything about how to modify the elements in the DXF export dialog. DXF export seems to be still the same like in 2005.
I have to admit that I don't have an AutomationPro license but I think the documentation is not depending on any licensed features. :-)
Regards,
Chris
OH, the question is really about DXF Export and not about the General Interfaces dialog! The code in the above script searches for the "General Interfaces" dialog but I see that is bogus and those lines shouldn't be in the script. :-)
So to answer the question: DXF export is not currently available in the engines nor do I know when it will be available.
However, we might be able to do something with the existing Automation methods in conjunction with the DXF dialog. Take a look at this:
Option Explicit
Dim app: Set app=GetObject(,"MGCPCB.Application")
Dim doc: Set doc=app.ActiveDocument
call ValidateServer(doc)
' invoke the DXF export command
app.Gui.ProcessCommand("File->Export->DXF...")
' get a reference to this DXF dialog
Dim dlgObj: Set dlgObj = app.Gui.FindDialog("DXF Export")
' get a reference to the edit string which holds the output file name
Dim editbox: Set editbox = dlgObj.FindEditBox("DXF output file:")
' change name of output file
editbox.Text = "c:\esmith\Ed.dxf"
' find the OK button
dim OKButton: set OKButton = dlgObj.FindButton("OK")
' and press it to execute the dialog
call OKButton.Click
MsgBox "DXF Export done"
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
The above script will bring up the DXF export dialog, load the last output scheme (controlled by the file \config\DXFSettings.txt in the job directory), change the output filename and press the OK button to get the DXF file generated. If you want a mechanism like this to generated a DXF file with the press of a button you must have a number of predefined scheme you output otherwise you would just use the dialog... So, you could generate your own scheme (or schemes) using the DXF dialog and store them in a central location. Then you could modify the above script to use the FileSystemObject to copy the scheme from the central location over the top of the existing config\DXFSettings.txt file before the dialog is invoked from the above script. This way the dialog will be prepopulated with the required scheme and the script will press the OK button and generate the DXF file with the contents specified by the scheme.
I hope this helps.
Regards, Ed
Hi Ed,
Thank very much. Your method works well and I used to use setting files under \config.
the difficulty to me is that I don't how know to use API find some fields in the dialog GUI.It seems not all fields supported by Automation API. For example, I can't use API to control which drill symbol to assign
Another way I like hkp.files is that HKP give a robust way to translate Expeditionpcb database to Allegro database)_:
Yanfeng
Does automation already provides intreface to modify pinmapping data (and in general all that data in PDB)?
Pinmapping is readonly at this point in time. It's one of those few items that does not have a 'write' mechanism.
Regards, Ed
And will it have write method in the future?
Apparently it is available in the newly released 2007.5... So yes!
Well, then it may really worth looking into. Another question would be to interface Python with automation.
I have no experience with this but I believe using Python with Automation is possible. Python's win32.client package has support for COM. Also see the MakePy utility in this package.
I also believe that ActiveState (www.activestate.com) have excellent integration between their Python and the Microsoft .Net framework and COM.
Regards, Ed