Skip to main content
1-Visitor
Jun 22, 2022 7:43 AM UTC
Question

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

5 replies

14-Alexandrite
Jun 22, 2022 8:05 AM UTC

Hello,

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.
Translate
1-Visitor
Jun 22, 2022 8:44 AM UTC

Thanks for your explanation and prompt reply @FabianWolf

 

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

 

Regards,

Harsh Patel

Translate
15-Moonstone
Jun 22, 2022 12:38 PM UTC

 

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);
ProWindowCurrentSet(WindowId1);
tkerr = ProMdlRetrieve (name_ext, PRO_MDL_ASSEMBLY, &mdlSeriesAssy);
ProMdlDisplay(mdlSeriesAssy);

Translate
21-Topaz I
Jun 23, 2022 11:41 AM UTC

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: https://www.ptc.com/en/support/article/cs123972 

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.

Translate
FV_01
Jun 27, 2022 4:55 PM UTC

This is why:

FV_0-1656348335755.png

try to build a simple async app.

HIH.

 

Translate