Skip to main content
1-Visitor
August 7, 2020
Question

How to connect to a Creo session from two available session | VBAPI

  • August 7, 2020
  • 2 replies
  • 4621 views

Hello

 

As we know CCpfcAsyncConnection.Connect would give ambiguity exception if there are more than one Creo session is there. In such case, GetConnectionId will help us to connect to specific Creo session. To get connection ID, we have option to get so by API GetConnectionId. I am having confusion of usage of this API GetConnectionId , i.e. how to use this same API to identify two or three different connection string based on number of active sessions. 

 

Any thought would be helpful as I would like to give option to use end application based on session model name his / her application is going to get connected for automation purpose.

 

Thanks and Regards

KEtan

2 replies

RPN
18-Opal
August 9, 2020

extern ProError ProEngineerConnect( char *proe_session_id, char *display,
char *user, char *textpath,
ProBoolean allow_random,
unsigned int timeout_sec,
ProBoolean *random_choice,
ProProcessHandle *p_handle );

I don’t get your point, here you can use the session ID on connect. 

1-Visitor
August 10, 2020

Hi

 

We used to pass null string as session ID and it connects to Creo session if there is only one Creo running...

 

However, it fails to connect of there are more than one session. How to know session ID before connecting is my concern.

15-Moonstone
August 10, 2020

I know its not much since you most likely know all that is mentioned here, but some info can be found here:

https://creocustomization.com/get-creo-connection-id-using-vb-api/

Not much help to your original question though.

August 10, 2020

hi all,

Ketan,

in pro/toolkit - the common way dealing with connection handles is to run a sync app (with auto start) which does nothing other than having user_init(...) writing the connection string (which is an output of ProEngineerConnectIdGet(...)) to a text file at some known location and writing whatever info an async app would use to identify this pro/e session as one which the async app would need to connect to. In the async app, the first order of business would be to scan the known location for files containing a connection string, do some logic to extract the wanted connection string, and to connect to pro/e session with ProEngineerConnect(...) using the extracted connection string as the first argument and using PRO_B_FALSE to disable random connections.

 

The combo ProEngineerConnect(...) -> ProEngineerConnectIdExtract(...) is used in cases when an async app would connect at random Pro/E session at first , do whatever, disconnect and than would need to connect to the same session again. In that scenario the ProProcessHandle output argument would be processed by ProEngineerConnectIdExtract(...) and the connection string would be stored for future use.

HIH.

FV.

 

1-Visitor
August 10, 2020

This seems good... We do have toolkit license and can be implemented like what you have mentioned... I believe the id fetched from toolkit api and written into text file would work if used by VBAPI session connect... If this is perfect, we are done it seems... 

 

Additionally , if one has no toolkit license and only vbapi is there, is it not at all possible to connect to one session provided more than one session are running by end user before app got started..?

August 10, 2020

don't know about VB. In case of no pro/toolkit license I would use JLink ( free java otk) for a sync app.