Is there a way to check if an other Dxdesigner application is running and to connect to it?
With expedition PCB this is possible with PcbApp.Utility.FindApplication(cnt) but I couldn't find anything like this for DxDesigner.
If you do set one to the get obect and open the second one yourself, it should work.
app1 = getobject(...)
app2 = createobject(...)
I Don't want to create a new object but is for a vbs script started in expedition PCB that needs to connect to the dxdesigner project of this board (which is already opened) but if you have 2 dxdesigner programs started it will connect to the first one which might be the incorrect project.
I added a check to see if PCB Path on the active design matches the PCB path from Expedition PCB to stop the script but would be better if I can somehow connect to other instances of Dxdesigner to find the correct one.
I stumbled over the same issue and opened two SRs in 2010, 2332128450 for DxD and 2332128540 for EXP (stucked at getObject(), not aware of 'FindApplication').
Both were closed without solution.
Now I've learned at least how to do it for EXP, thanks.
Since I develop in C#, I came up with the following solution:
internal static class RunningObjectTable
// call into ole22.dll to retrieve the GetRunningObjectTable function
private static extern int GetRunningObjectTable(int reserved,
out IRunningObjectTable prot);
// call into ole32.dll to retrieve the CreateBindCtx function
private static extern int CreateBindCtx(int reserved,
out IBindCtx ppbc);
/// Returns a list of instance objects from the running objects table (ROT)
/// that match the specified application name (<paramref name="appName"/>).
/// <param name="appName">Name of the application to find instances for.</param>
/// <returns>A list of instances of the specified application.</returns>
public static IEnumerable<T> GetInstancesWithName<T>(string appName)
IMoniker monikers = new IMoniker;
List<T> instances = new List<T>();
GetRunningObjectTable(0, out runningObjTable);
// loop through the ROT looking for appName
while (monikerEnum.Next(1, monikers, IntPtr.Zero) == 0)
CreateBindCtx(0, out ctx);
string runningObjName = string.Empty;
monikers.GetDisplayName(ctx, null, out runningObjName);
// when found, add the instance object to the List
runningObjTable.GetObject(monikers, out runningObjValue);
This class finds all instances of DxDesigner (or any other application, for that matter) in the Running Object Table (ROT) and casts them to type T. It allows for the following:
var instances = RunningObjectTable.GetInstancesWithName<ViewDraw.Application>("Viewdraw.Application");
foreach (var instance in instances)
string instancePathProject = instance.GetProjectData().GetProjectFilePath();
if (instancePathProject == _pathProject)
this.Application = instance;
Or, you could pop up a dialog asking the user which instance they'd like to "connect" to, as I do for Expedition.
Retrieving data ...