since I can't find any thread of anyone using C# with MGCPCB Automation, I doubt anyone can help me, but here's my shot:
Well, as I said, I'm using a C# application with Automation, and until now I figured out how to get it working (if anyone is interested, I can provide a basic setup how to do it).
One of the features I included is that it is possible to start my application from Expedition PCB, through a menu item.
The problem is that the only way I found to open a PCB in C# was by calling the "OpenDocument" function from a ExpeditionPCBApplication object.
This will create a new instance of Expedition, and because it is already opened, I get a "Read only" warning.
That's not realy a problem, but the user might have changed the design already without saving, and thus my C# application will get an "outdated" design.
So I start looking, and found that in VBScript you can attach to a running instance with a GetObject call.
Though C# doesn't have this function, I found that you can use Marshal.GetActiveObject.
But the problem is that when more designs are opened at the same time, GetActiveObject will always attach to the design which was opened first.
So when I first open one design, and then open a second design, and start my application from the second design, the application will be attached to the first design.
(I guess the same will happen when using GetObject from a VBScript...)
But when I want to attach to a specific instance by enumerating all running Monikers, and then selecting the moniker with the PCB design file as display name, I get an "Invalid interface" error.
Does anyone know how I can solve this, or at least if it is possible in VBScript to attach to a specific instance?
Thanks in advance.
JP de Ruiter