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

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

How to display current model name in popup dialog

kguru
1-Newbie

How to display current model name in popup dialog

Anybody explain me.I am  a beginner in protoolkit

Thanks

5 REPLIES 5
sjuraj
13-Aquamarine
(To:kguru)

I can only give you an exmple in J-link:

Session session = pfcGlobal.GetProESession();

Model model = session.GetCurrentModel();

String modelName = model.GetFullName();

session.UIShowMessageDialog(modelName, null);    // this brings default Creo ui dialog with name of current model

kguru
1-Newbie
(To:sjuraj)

Thanks.I need protoolkit coding

msteffke
13-Aquamarine
(To:kguru)

I do something similiar what your asking. ParamValString is a function I have that gets the parameter value for a string param.

Basically I print my info to a text file, then open the text file using ProInfoWindowDisplay.

You could use ProUIDialog functionality as well for a fancier method.  I just found this method very simple to do.

strcpy(mypar, ParamValString("NAME", modelitem));

fprintf(fp," Parameter information for %s\n",mypar);

fprintf(fp,"------------------------------------------------------------------\n");

fprintf(fp,"------------------------------------------------------------------\n");

fprintf(fp," DESCRIPTION: %s\n",ParamValString("DESCRIPTION", modelitem));

fprintf(fp," NAME: %s\n",ParamValString("NAME", modelitem));

fprintf(fp," MATERIAL: %s\n",ParamValString("MATERIAL", modelitem));

fprintf(fp," UNIT_OF_MEASURE: %s\n",ParamValString("UNIT_OF_MEASURE", modelitem));

fprintf(fp,"------------------------------------------------------------------\n");

fprintf(fp,"------------------------------------------------------------------\n");

 

  ProStringToWstring (wfname, "c:\\temp\\ViewPars.txt");

  status = ProInfoWindowDisplay (wfname, NULL, NULL);

sully7
13-Aquamarine
(To:kguru)

Hi Keerthana,

I posted this a few days ago - it may help: Re: create popup menu with button clik

Mark's code is definitely useful ( I actually am a huge fan of the ProInfoWindowDisplay ), but without having the custom "ParamValString" method, here's another method that may work for you:

ProError creoTest() {

    ProError err = PRO_TK_NO_ERROR;

    ProMdl current_model;

    ProMdlName current_model_name;

    err = ProMdlCurrentGet(&current_model);

    if (err != PRO_TK_NO_ERROR) { return err; } // in case you don't have a model open

    err = ProMdlMdlnameGet(current_model, current_model_name);

    ProUIMessageButton *buttons; // an array of buttons

    ProUIMessageButton ok_button = PRO_UI_MESSAGE_OK;

    ProUIMessageButton cancel_button = PRO_UI_MESSAGE_CANCEL;

    err = ProArrayAlloc(0, sizeof(ProUIMessageButton), 1, (ProArray*)&buttons);

    err = ProArrayObjectAdd((ProArray*)&buttons, -1, 1, &ok_button);

    err = ProArrayObjectAdd((ProArray*)&buttons, -1, 1, &cancel_button);

    ProUIMessageType message_type = PROUIMESSAGE_INFO;

    ProUIMessageButton user_picked_this_one = PRO_UI_MESSAGE_CANCEL; // set an initial value just in case

    err = ProUIMessageDialogDisplay(message_type, L"Current Model Name", current_model_name, buttons, ok_button, &user_picked_this_one);

    if (err == PRO_TK_NO_ERROR && user_picked_this_one == PRO_UI_MESSAGE_OK) {

      return PRO_TK_NO_ERROR; // hooray! ^_^

    }

    return PRO_TK_USER_ABORT;

  }

NOTE: If you are using Creo 2 - then you will need to use "ProName" instead of "ProMdlName", and "ProMdlNameGet" instead of "ProMdlMdlnameGet".

Thanks,

James Sullivan

CadActive Technologies

President & Founder

President & Founder
CadActive Technologies - www.cadactive.com
kguru
1-Newbie
(To:sully7)

Thanks sir. Now It work.

Top Tags