When multiple CATIA sessions are open GetObject returns the first session. Is it possible to target a specific session CATIA session? I have noticed that when an external program accesses CATIA via COM or the internal VBA editor of CATIA is opened, a child process (CATVBAHostingApplication.exe) starts and stays open. Without terminating this process, the VBA editor cannot be accessed from the second CATIA process. Can anyone explain how CATVBAHostingApplication.exe interacts with CATIA and if it can be manipulated to target a specific instance?
Is it possible to target specific COM Instances of CATIA?
3.2k views Asked by Jon At
1
You can target specific instances of CATIA but you have to use the program ID number and some clever coding. What language are you using? From what program are you working? Are you making a stand alone EXE or console app?
Frankly, I have written subs that parse thru the list of running applications and gets this information, but it's a pain. Like when you are accessing multiple instances of Excel, you use the file name that is open, like the workbook in Excel, to access via GetObject. But first you need to do the parsing that I mentioned before.
A much easier approach: Whenever I need multiple instances of Catia open simultaneously, I use CreateObject instead of GetObject, and have my external program launch all my instances.
CATVBAHostingApplication.exe was a [frankly sloppy] solution to maintaining VBA in the 64-bit version of CATIA. VBA in 32-bit CATIA used to be a great thing. Super fast, didn't refresh all the f-ing time, etc etc. Once 64-bits came around, Dassault didn't know what to do with the VBA appendage. So they made this CATVBAHostingApplication.exe to run along side CATIA, and it is slow, needlessly refreshes the CATIA display, and has lots of bugs. It's not uncommon to have your CATVBAHostingApplication.exe running even though you killed CATIA, and when you reopen, the old session is still holding on to your CATVBA files. I probably kill the CATVBAHostingApplication.exe at least three times a day from the Task Manager.
Whenever you initiate some sort of API, whether it be inside of CATIA via ALT+F8 or ALT+F11, or if you connect via COM, this process is always started if you like it or not. There is no workaround. I've programmatically used a similar method I mentioned above to parse the tasks list to programmatically use TaskKill to stop the CATVBAHostingApplication.exe if that is a necessary thing. But for the most part, if I'm connecting via COM, it doesn't matter to the client if that is running until the next time they restart Windows. They aren't usually programming in VBA anyway, just using my plug-ins and modeling manually.
Lastly, I'm not sure why you are connecting to the CATVBAHostingApplication.exe (from what I read in your post), and shouldn't you be connecting to CATIA directly? If you have loaded the references for CATIA, then you don't need to connect to the VBA editor? Maybe I'm misunderstanding. HTH