The PTC Community is on temporary read only status in preparation for moving our community to a new platform. Learn more here
Hello there,
As you can see , i am trying build a simple full asynchronous mode of toolkit application to connect to a running creo session, later i will try to fetch the component details. But as off now i am stuck with this errors , can anyone help me.
1) I am not sure if i have included correct libraries in project settings.
2) stuck in these errors
is there any manual to dive deep to study on full asynchronous mode
Hi @TP_9862373,
Thank you for your question.
Your post has not yet received any response. I am replying to raise awareness. Hopefully, another community member will be able to help.
Also, feel free to add any additional information you think might be relevant. It sometimes helps to have screenshots to better understand what you are trying to do.
Best Regards,
Vivek N
Community Moderation Team
most likely there was a missing library, an incorrect runtime library, an incorrect _DEBUG macro, or a combination of these.
It would be a good idea to post the Visual Studio Project Properties → C/C++ → Command Line text, as well as the Linker → Command Line text, instead of a blurry picture.
in c++:
/JMC /ifcOutput "dim_async_2\x64\Debug\" /GS /W0 /Zc:wchar_t /I"C:\Program Files\PTC\Creo 11.0-M050\Common Files\protoolkit\includes," /ZI /Gm- /Od /Fd"dim_async_2\x64\Debug\vc143.pdb" /Zc:inline /fp:precise /D "_ITERATOR_DEBUG_LEVEL=0" /D "PRO_USE_VAR_ARGS" /D "_MBCS" /errorReport:prompt /WX- /Zc:forScope /RTC1 /Gd /FU"C:\WINDOWS\assembly\GAC_64\System.Data\2.0.0.0__b77a5c561934e089\System.Data.dll" /FU"C:\WINDOWS\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll" /FU"C:\WINDOWS\assembly\GAC_MSIL\System.Xml\2.0.0.0__b77a5c561934e089\System.Xml.dll" /MT /FC /Fa"dim_async_2\x64\Debug\" /EHsc /nologo /Fo"dim_async_2\x64\Debug\" /Fp"dim_async_2\x64\Debug\dim_async_2.pch" /diagnostics:column
in linker :
/OUT:"C:\Users\prithivi\Desktop\creo\vs_professional\dim_async_2\x64\Debug\dim_async_2.exe" /MANIFEST /NXCOMPAT /PDB:"C:\Users\prithivi\Desktop\creo\vs_professional\dim_async_2\x64\Debug\dim_async_2.pdb" /DYNAMICBASE "protk_dll_NU.lib" "ucore.lib" "ws2_32.lib" "netapi32.lib" "mpr.lib" "pt_asynchronous.lib" "psapi.lib" "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /DEBUG:FULL /MACHINE:X64 /INCREMENTAL /PGD:"C:\Users\prithivi\Desktop\creo\vs_professional\dim_async_2\x64\Debug\dim_async_2.pgd" /SUBSYSTEM:CONSOLE /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:"dim_async_2\x64\Debug\dim_async_2.exe.intermediate.manifest" /LTCGOUT:"dim_async_2\x64\Debug\dim_async_2.iobj" /ERRORREPORT:PROMPT /ILK:"dim_async_2\x64\Debug\dim_async_2.ilk" /NOLOGO /LIBPATH:"C:\Program Files\PTC\Creo 11.0-M050\Common Files\protoolkit\x86e_win64\obj" /TLBID:1
Just check the make examples in the installed toolkit folder for asynchronous apps. Here is all what you need to compile, next enhance by your needs.
@RPN i managed to build a exe file but now when i try to connect to a running creo session, even based on a example file given, using pro_engineer_connect. i get -4 which means creo session not found error. is there any guide or document to read on it , how to do these ,
I'm sure you have already checked this but remember to set an environment variable for PRO_COMM_MSG_EXE
This is probably a good idea, path issues seems to be already solved 🙃
About 2400 pages of toolkit manuals are a lot to read through 🎯 but you may get rewardedヤ
And in my point of view, PTC gives you the tools and how PTC thinks a working environment should be focus on. Your job is to understand this, but this is not documented.
So make sure you can compile your apps with a couple off variables by your needs.
yes @RPN you are correct , path is already fixed , but i am clueless on how to connect even i have referred the example and used pro_engineer_connect to connect to a running session but i got -4 error. any pdf documents or examples or videos would help me , please
one hint, do i need PROTK.dat file for this asnychronous mode exe file to connect to a creo session ?
No you don’t need that. Just the env var PRO_COMM_MSG_EXE with full path incl. extension.
Don‘t forget, you may need an event loop, but check the examples.
@RPN thanks for the reply, but can anyone suggest me a document or material specifically for this full asynchronous mode usage, to avoid that -4 error .
stat = ProEngineerConnect(„“, NULL, NULL, NULL, PRO_B_FALSE, 2000,&rnd,&hnd);
For the session ID you use an empty string, like above?
/*
proe_session_id - This argument can be either empty string or
identification string returned by
ProEngineerConnectIdExtract. If it is ID string, the
Creo Parametric TOOLKIT application will try to connect to the
specified Creo Parametric session; if this attempt fails,
the application will try to connect to any Creo Parametric
session.
*/
-4 = PRO_TK_E_NOT_FOUND - No Creo Parametric session with the specified
characteristics could be found, or information on
the session could not be read from the name server.
So I assume Creo is running if you start you asyn exe!
@RPN This is my code ,
ProError err;
ProProcessHandle p_handle = nullptr
// Connect to an EXISTING running Creo session
err = ProEngineerConnect(
NULL, // display (NULL = use existing session)
NULL, // startup file
NULL, // application name
NULL, // application path
PRO_B_TRUE, // multi-threaded
10, // timeout seconds
NULL, // connection ID (NULL = first available)
&p_handle
);
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
);
The last and the second to last are return values, not input values!
for
NULL, // connection ID (NULL = first available
provide a Boolean like &rnd, here you will see if a random session was used.
This is not a multithread info
PRO_B_TRUE, // multi-threaded
Just if you allow a random choice if more than one sessions are running, at the beginning I would use the false value.
@RPN I have changed to the below code now, but the error -4 is still there.
err = ProEngineerConnect(
"", // arg1: proe_session_id — "" finds any session
NULL, // arg2: display — NULL matches any display
NULL, // arg3: user — NULL matches any user
NULL, // arg4: textpath — "" if no message files
PRO_B_FALSE, // arg5: allow_random — pick any if multiple found
2000, // arg6: timeout_sec — 30 seconds
&random_choice, // arg7: random_choice — OUTPUT, must NOT be NULL
&proe_handle // arg8: p_handle — OUTPUT process handle
);
Hmm, that is weird.
Side node
arg5, if this is false, the connection will fail if more than one creo session is detected. Make sure at the beginning that you have only one xtop.exe in you process viewer.
If this argument is true, the random choice returns if you had more than one session.
And yes the value is in seconds, not Milli seconds, so a small second value like 10 should be enough.
Hi @RPN , i get this output
=== Creo 11 Async Toolkit Launcher ===
PRO_COMM_MSG_EXE = C:\PROGRA~1\PTC\CREO11~1.0-M\COMMON~1\X86E_W~1\obj\PRO_CO~1.EXE
[OK] dim_async_2.exe found
[OK] nmsd already running
[OK] nmsd is running
[OK] Creo is running
[INFO] Adding firewall exception for nmsd...
Launching dim_async_2.exe...
PRO_COMM_MSG_EXE = C:\PROGRA~1\PTC\CREO11~1.0-M\COMMON~1\X86E_W~1\obj\PRO_CO~1.EXE
ProEngineerConnect result: -4
Failed to connect! Error: -4
for the code
err = ProEngineerConnect(
session_id, // arg1: proe_session_id — "" finds any session
NULL, // arg2: display — NULL matches any display
NULL, // arg3: user — NULL matches any user
NULL, // arg4: textpath — "" if no message files
PRO_B_FALSE, // arg5: allow_random — pick any if multiple found
30, // arg6: timeout_sec — 30 seconds
&random_choice, // arg7: random_choice — OUTPUT, must NOT be NULL
&proe_handle // arg8: p_handle — OUTPUT process handle
);
std::cout << "ProEngineerConnect result: " << err << std::endl;
if (err != PRO_TK_NO_ERROR) {
std::cerr << "Failed to connect! Error: " << err << std::endl;
return -1;
}
Be careful with the short path, try the full path and use quotes. I never use this, but I may wrong.
Instead of
PRO_COMM_MSG_EXE = C:\PROGRA~1\PTC\CREO11~1.0-M\COMMON~1\X86E_W~1\obj\PRO_CO~1.EXE
use
set PRO_COMM_MSG_EXE =„C:\Programm Files\…“
I‘m not sure about the firewall, because it is a local connection. So you may need to ask your security if there are issues with Rpc connections.
Creo was original build for Unix systems, so I‘m not sure if PTC rely with path data on windows environment.
I never used this short names, because they can change.
Did you validate the path inside the batch, so check if the common message exe exists based on your given var. For me it is looking like a typo.
And you give a session_id, is this empty?
To have an asyn session, you can start creo by a toolkit call as well.
from make examples (<PRO_TOOLKIT>/x86e_win64/obj), if async mode is needed, either use "make_async" or "make_async_md",
what was shown in the reply did not match any:
"protk_dll_NU.lib" "ucore.lib" "ws2_32.lib" "netapi32.lib" "mpr.lib" "pt_asynchronous.lib" "psapi.lib" "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib"
"make_async":
# Libraries
PTCLIBS = $(PROTOOL_SYS)/obj/protoolkit_NU.lib \
$(PROTOOL_SYS)/obj/pt_asynchronous.lib \
$(ICU_PATH)/ucore.lib \
$(ICU_PATH)/udata.lib
LIBS = kernel32.lib user32.lib wsock32.lib advapi32.lib mpr.lib winspool.lib netapi32.lib psapi.lib gdi32.lib shell32.lib comdlg32.lib ole32.lib ws2_32.lib
or "make_async_md":
# Libraries
PTCLIBS = $(PROTOOL_SYS)/obj/protkmd_NU.lib \
$(PROTOOL_SYS)/obj/ptasyncmd.lib \
$(ICU_PATH)/ucore.lib \
$(ICU_PATH)/udata.lib
LIBS = kernel32.lib user32.lib wsock32.lib advapi32.lib mpr.lib winspool.lib netapi32.lib psapi.lib gdi32.lib shell32.lib comdlg32.lib ole32.lib ws2_32.lib
the posted sample is indeed matching "make_install":
# Libraries
PTCLIBS = $(PROTOOL_SYS)/obj/protoolkit_NU.lib \
$(ICU_PATH)/ucore.lib \
$(ICU_PATH)/udata.lib
PTCLIBS_DLL = $(PROTOOL_SYS)/obj/protk_dll_NU.lib \
$(ICU_PATH)/ucore.lib \
$(ICU_PATH)/udata.lib
LIBS = kernel32.lib user32.lib wsock32.lib advapi32.lib mpr.lib winspool.lib netapi32.lib psapi.lib gdi32.lib shell32.lib comdlg32.lib ole32.lib ws2_32.lib
but "make_install" is for building a synchronous app - either EXE or DLL, basically if you would build the app with those libraries, the app would have no idea about asynchronous mode ( how to connect, disconnect, communicate with pro/e)
I thought he compiled successful the exe, and
ProEngineerConnect
and the other ProCore symbols/calls are only part of the asynchronous libs.
But fore sure you need to follow the given examples for creating an asynchronous app, so I hope for him that this is the root cause😉
pt_asynchronous.lib and protk_dll_NU.lib as well are part of the error output.
i have added the missing libraries from your message but i still get the same error,
=== Creo 11 Async Toolkit Launcher ===
PRO_COMM_MSG_EXE = "C:\Users\prithivi\Desktop\creo\vs_professional\dim_async_2\x64\Debug\pro_comm_msg.exe"
[OK] dim_async_2.exe found
[OK] nmsd already running
[OK] nmsd is running
[OK] Creo is running
[INFO] Adding firewall exception for nmsd...
Launching dim_async_2.exe...
PRO_COMM_MSG_EXE = "C:\Users\prithivi\Desktop\creo\vs_professional\dim_async_2\x64\Debug\pro_comm_msg.exe"
ProEngineerConnect result: -4
Failed to connect! Error: -4
These were my lib files,
pt_asynchronous.lib
;protoolkit_NU.lib;
ucore.lib
;udata.lib
;netapi32.lib;
wsock32.lib;
psapi.lib
;mpr.lib;
ws2_32.lib;
kernel32.lib;
user32.lib
;advapi32.lib;winspool.lib;gdi32.lib;shell32.lib;comdlg32.lib;ole32.lib;%(AdditionalDependencies)
"C:\Program Files\PTC\Creo 11.0-M050\Common Files\x86e_win64\obj\pro_comm_msg.exe" this was my actual path, it also shows the same error, so i copied the file to some other location and update it in environment and ran the exe but got the same error still.
This doesn’t make sense. Why are you debugging pro_comm_msg.exe at all?
For an async application, you should be debugging the build target.
For a sync application, you should attach the debugger to the running xtop.exe process.
In your batch
set PRO_COMM_MSG_EXE=„C:\Program Files\PTC\Creo 11.0-M050\Common Files\x86e_win64\obj\pro_comm_msg.exe“
Start Creo from one batch in „C:\Program Files\PTC\Creo 11.0-M05\*\bin\*start*.bat“
Start your exe, the exe should connect.
In Asyn Mode you can control Creo, you can even set the current model, in unmanned mode this is great, if you have a user on top, you need a couple of notification callbacks and an event loopヤ
Have fun!
@RPN ,
I have already set this
set PRO_COMM_MSG_EXE=„C:\Program Files\PTC\Creo 11.0-M050\Common Files\x86e_win64\obj\pro_comm_msg.exe“
in my batch file, but i cant start a creo as you mentioned using bat file, since i have a customized creo for my work, so i want the full-async code to connect the running creo session , where i have landed in -4 error.
@FV , i ididnt debug pro_com_msg.exe file, i debug only the file which i created , to check the environmental variable values , i have just printed it in command prompt window.
Yes, that is fine, but before you jump in your own environment make sure it is working at all. You need to figure out the root cause of your problem
So I would recommend to start out of the box, by just one start batch file, and if this is working go ahead.
Maybe your env will tweak vars and use old path info, which may lead to -4 *NOT_FOUND
