Showing results for 
Search instead for 
Did you mean: 
Showing results for 
Search instead for 
Did you mean: 

The PTC Community email address has changed to Learn more.

Unable to get Promdl handle


Unable to get Promdl handle

Hello all,


I am trying to register the server, create dummy workspace, checkout model and open the model in creo.


I am able to checkout the objects and retrieve in Creo using below code.



// here is necessary declaration
status = ProMdlnameRetrieve(lclmdlName, (ProMdlfileType)mdlType, &retrieveModal);
if (status == PRO_TK_NO_ERROR)
Logger::LogInfo("Model retrieved successfully");
/* Display the object */
status = ProObjectwindowMdlnameCreate(lclmdlName, (ProType)mdlType, &w_id);
status = ProWindowCurrentSet(w_id);
status = ProMdlDisplay(retrieveModal);
status = ProMdlWindowGet(retrieveModal,&w_id);
status = ProWindowCurrentSet(w_id);

status = ProWindowActivate(w_id);



After this code, some where in my code when I use "ProMdlCurrentGet" -> it doen't give me Promdl handle.


Am I doing wrong thing?


Thanks for the help in advance.

Harsh Patel



the problem is that ProMdlCurrentGet grabs the model pointer from the current native Creo window. Even if no model is displayed in session, there's still such a base window. ProMdlCurrentGet doesn't consider other windows like the object window you create to display the model. Also even setting the object window to be the current window, this fact doesn't change.


What you could do:

  • Memorize the retrieved model handle for later usage
  • Memorize the window id of your object window and call ProWindowMdlGet
  • Don't use an object window but display the retrieved model within a native Creo window instead.

Thanks for your explanation and prompt reply @FabianWolf


Can you please guide me how can I display the retrieved model within a Creo window ?



Harsh Patel


This always seems to get the job done for me.   I create a window, set it current,  then retrieve.


strcpy(strname, AssyName);
strcpy(strname_ext, AssyName);
strcat(strname_ext, ".asm");
ProStringToWstring(name, strname);
ProStringToWstring(name_ext, strname_ext);
ProObjectwindowCreate(name_ext, PRO_MDL_ASSEMBLY, &WindowId1);
tkerr = ProMdlRetrieve (name_ext, PRO_MDL_ASSEMBLY, &mdlSeriesAssy);

21-Topaz I

ProMdlCurrentGet does not get the handle to the model you need in session. Does it by chance return PRO_TK_BAD_CONTEXT?

If yes then the following article may apply: 

Depending on the mode, the call sequence may differ (like it has been uttered by other posts).

If ProMdlCurrentGet returns another status, feel free to share it.


This is why:


try to build a simple async app.