Asynchronous Application

For a head start on Asynchronous applications, please read my previous post “Nuts and Bolts” or follow the link. I have given brief summary about the Asynchronous mode. For more details refer to the section “Asynchronous Mode” from the toolkit user guide.

It is very important for an asynchronous application to have the following environment variable set.
On Windows:
PRO_COMM_MSG_EXE = (ProENGINEER_LOADPOINT)\i486_nt\obj\pro_comm_msg.exe
On Unix:
% setenv PRO_COMM_MSG_EXE (ProENGINEER_LOADPOINT)//obj/pro_comm_msg
Here is an example of Simple Asynchronous application. It launches a Pro/ENGINEER session and then create a PART, saves it and then Displays it.
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/*************************************************\
This is an Asynchronous application which launches
a Pro/E session and then create a PART and save and
Display it. It also activates the window
\*************************************************/

/*************************************************\
Pro/Toolkit Includes files
\*************************************************/
#include "ProToolkit.h"
#include "user_tk_error.h"
#include "ProCore.h"
#include "ProMdl.h"
#include "ProObjects.h"
#include "ProSizeConst.h"
#include "ProUtil.h"
/*************************************************\
Main Function
\*************************************************/
int main( int argc, char *argv[] )
{
char *arg_ptr;
int w_id;
ProName part_name;
ProError status;
ProSolid p_part, model;
/*************************************************\
Pro/ENGINEER launched asynchronously
\*************************************************/
if ( argc == 3)
{
arg_ptr = argv[1];
status=ProEngineerStart(arg_ptr,"");
printf("\n\n*The ProEngineerStart status: %d",status );
}
else
{
printf("Use Syntex: toolkit \n"); /* make sure to use a unique name for the Pro/E part, everytime the application is launched*/
exit(1);
}
/*************************************************\
Set up the part name from the argument list.
\*************************************************/
arg_ptr = argv[2];
ProStringToWstring(part_name,arg_ptr);
/*************************************************\
Retrieve a part with that name.
\*************************************************/
status=ProSolidCreate (part_name, PRO_MDL_PART, &p_part);
if (status!=PRO_TK_NO_ERROR)
{
printf("\n\n* Failed to Create part %s", arg_ptr); /* If the part file name exist on the working folder, Pro/E will exit giving error*/
}
/*************************************************\
Save the part
\*************************************************/
status=ProMdlSave((ProMdl)p_part);
printf("\n\n*The ProMdlSave status: %d",status );
if (status!=PRO_TK_NO_ERROR)
{
ProEngineerEnd(); /* If there is a specials character(e.g.#^%~ ) in the model file name, Exit Pro/E */
}
/*************************************************\
Retrieve the model
\*************************************************/
status = ProMdlRetrieve(part_name, PRO_MDL_PART, &model); /*It neither displays the model nor makes it the current model*/
printf("\n\n*The ProMdlRetrieve status: %d",status );
/*************************************************\
Display the Model
\*************************************************/
status = ProMdlDisplay((ProMdl)model);
printf("\n\n*The ProMdlDisplay status: %d",status );
/*************************************************\
Activate the Model
\*************************************************/
status = ProMdlWindowGet(model, &w_id);
status = ProWindowActivate(w_id);
return(0);
}
/*************************************************\
End of Application
\*************************************************/
If you need any help in compiling and running this application please get in touch with me at Alxn.Page@gmail.com. Thanks for your valuable time in reading through…. Happy coding, God Bless.

_________________________________________________________

TRADEMARKS: Pro/ENGINEER, Wildfire, Pro/Toolkit, Pro/Develop, J-Link, Pro/Web.Link and VB API are the registered trademarks of PTC (http://www.ptc.com/). All other products or services mentioned in this blog are the trademarks or service marks of their respective companies or organizations.

No comments:

Post a Comment