I want to write a plugin for EPDM that opens SolidWorks and then processes some drawings: removing blocks and so on. I would put this plugin as a task on people's computers so that those in our office who don't have SolidWorks can run it and have a result returned to them. This means that the task runs on those computers with SolidWorks (SW from now on because I'm sick of the extra typing), potentially getting in the way of people actively using SW.
So I want C# to open a second SW process in the background. How do I do this? I can attach to an already running process as per the following section of code:
SldWorks.SldWorks swApp = (SldWorks.SldWorks)System.Runtime.InteropServices.Marshal.GetActiveObject("SldWorks.Application");
This throws a COMException if there isn't a running SW process, which is fine; I can capture this when I want to. My thought was that since that this returns the currently running SW process, running the following should start a new process:
SldWorks.SldWorks swApp = new SldWorks.SldWorks();
For some reason, this attaches to the already running SW as opposed to creating a new one. I understand wanting this in many situations - it would often be more useful to get either a currently running SW or start a new one if one isn't running, but when you want a second one, this isn't what you want.
Thanks for any light people can shine on this,