Start specific instance of BricsCAD

I want to start BricsCAD by COM and found this solution to do it:
https://forum.bricsys.com/discussion/33619/how-to-get-an-instance-of-bricscad18-by-calling-activator-createinstance-from-c-net

I also found that one can start a specific version if you add 19.0 to the progId:
const string strProgId = "BricscadApp.AcadApplication"; => const string strProgId = "BricscadApp.AcadApplication.19.0";

How can one choose to start a specific language if more than one is installed?
I also often want to start specific version of same language (I copy the Bricsys folder in the Program Files). This is due to debugging reasons.
Therefor I currently have a setting with the path to the bricscad.exe that I want to launch. Can I somehow pass this to the Activator?

Comments

  • how can i get the bricsys process id? I have not found any info on COM revealing the proces id.
    I found there is a lisp call (getpid) that shows it. But I have not found how I can pass this info back to .Net.

    Original question is also still open.

  • Dear Karel,

    from COM/NET, you could run "evaluateLisp(string)" where 'string' is just the (getPID) call ... should return a (long) integer back to caller;
    and fortunately, evaluateLisp() is a synchronous call :-)

    For the language version : I assume, there is no way to specify that via COM, as the program ID string has no reference to language :-(
    But you might scan/parse the Registry, as each installation has its own language (sub-)key ...
    then, you might start the bricscad.exe from the particular folder (assuming, multiple language versions are installed into different folders), using WinExec() and similar, but not starting via COM "GetObject()" resp. "GetOrCreateObject()" ...

    hope this helps a bit ?
    many greetings !

  • Torsten,

    the evaluateLisp works fine. Thanks for the tip.

    On the language, if I start the application by CreateProcess(), and there was already a running process, then how do I tell COM to connect to the new created process?
    In fact I would also like to start multiple BricsCAD instances to be able to run multiple script at the same time (up to 8 instances).

  • Dear Karel,

    "CreateProcess()" is a Windows SDK function ... it is a bit difficult to retrieve the COM object for that particular instance then.
    The only way I see is to start via COM - using "CreateObject()" COM function ... this directly returns the IAcadApplication instance of that started COM instance.

    A script or Lisp running inside that new instance always connects to that instance - so the only problem is

    • start via Windows SDK CreateProcess
    • get the COM instance for it

    meaning, it is the "mix" of mechanisms which causes the trouble ... using only COM via CreateObject() should help, but it will require some changes in the code of your (external) application.

    hope this helps a bit ?
    many greetings !