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

Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X

Unable to get Promdl handle

HP_10319083
4-Participant

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 5

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.

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

msteffke
14-Alexandrite
(To:HP_10319083)

 

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);

remy
21-Topaz I
(To:HP_10319083)

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.

FV
17-Peridot
17-Peridot
(To:HP_10319083)

This is why:

FV_0-1656348335755.png

try to build a simple async app.

HIH.

 

Announcements


Top Tags