In this section we will build a skeleton synchronous Pro/Toolkit application from the scratch. You should have a compiler to compile code. In this example I will be using the Microsoft Visual C++ 6 and Pro/ENGINEER Wildfire 2.0. I will use the command prompt for compiling the code with the help of PTC provided standard make files. Create a folder and copy the "make_basic" file from the "[TK_LOADPOINT]/ [MACHINE]/obj" folder. Now open the file with any text editor and edit the text in the file as shown below:
~~~~~~~~~~~~~~~~~~~~
Line#23 -->> EXE = pt_basic.exe change it to EXE = tkapp.exe ( we will call our application "tkapp")
Line#24 -->> EXE_DLL = pt_basic.dll change it to EXE_DLL = tkapp.dll
Line#27 -->> PROTOOL_SRC = ../../../protoolkit change it to PROTOOL_SRC = [PROE_LOADPOINT]/protoolkit (this is required for the compiler to know the location of the library file and the include files of Pro/Toolkit)
Line#29 -->> PRODEV_SRC = ../../../prodevelop change it to PRODEV_SRC = [PROE_LOADPOINT]/prodevelop (this is required for the compiler to know the location of the library file and the include files of Pro/Develop)
Line#73 -->> OBJS = pt_basic_src.obj pt_utils.obj change it to OBJS = tkapp.obj (we indicate that there will be an intermediate file with the name tkapp.obj created)
Line#94 -->> pt_basic_src.obj: $(PROTK_APPLS)/pt_basic/pt_basic_src/pt_basic_src.c
$(CC) $(CFLAGS) $(PROTK_APPLS)/pt_basic/pt_basic_src/pt_basic_src.c change it to tkapp_src.obj: tkapp.c
Remove the line starting with "pt_utils.obj" completely.
Line#24 -->> EXE_DLL = pt_basic.dll change it to EXE_DLL = tkapp.dll
Line#27 -->> PROTOOL_SRC = ../../../protoolkit change it to PROTOOL_SRC = [PROE_LOADPOINT]/protoolkit (this is required for the compiler to know the location of the library file and the include files of Pro/Toolkit)
Line#29 -->> PRODEV_SRC = ../../../prodevelop change it to PRODEV_SRC = [PROE_LOADPOINT]/prodevelop (this is required for the compiler to know the location of the library file and the include files of Pro/Develop)
Line#73 -->> OBJS = pt_basic_src.obj pt_utils.obj change it to OBJS = tkapp.obj (we indicate that there will be an intermediate file with the name tkapp.obj created)
Line#94 -->> pt_basic_src.obj: $(PROTK_APPLS)/pt_basic/pt_basic_src/pt_basic_src.c
$(CC) $(CFLAGS) $(PROTK_APPLS)/pt_basic/pt_basic_src/pt_basic_src.c change it to tkapp_src.obj: tkapp.c
Remove the line starting with "pt_utils.obj" completely.
~~~~~~~~~~~~~~~~~~~~
Save the file and exit the editor. Now the second task is to get the source code going. To start with, we will write a small program in Pro/Toolkit. As mentioned in my previous blog, for a synchronous application the requirement is to have a user_initialize() and a user_terminate() function. We will open a text editor again and write the code as shown below (The name of the code file should be tkapp.c):
~~~~~~~~~~~~~~~~~~~~
#include "ProToolkit.h" // This include file is a must
/********************************/
int user_initialize() // This is a must for sync applications
{
/********************************/
int user_initialize() // This is a must for sync applications
{
printf("\nHello Pro/Toolkit World !!\n");
return (0);
}
/********************************/
void user_terminate() // This is a must for sync applications
{
printf("\nGoodbye !!\n");
return (0);
}
/********************************/
void user_terminate() // This is a must for sync applications
{
printf("\nGoodbye !!\n");
}
~~~~~~~~~~~~~~~~~~~~
Save the file as tkapp.c in the same directory which was created in step 1. Open a command prompt and then go to the directory which was created in step 1. At this point you will have to set the environment for using Microsoft Visual C++ tools on the command window. You will type something like this on the command prompt "C:\Program Files\Microsoft Visual Studio\VC98\Bin\VCVARS32.bat" (The path could vary if you have the "Microsoft Visual Studio", installed on a different folder). After running this batch file (VCVARS32.bat), you will get a system message as “Setting environment for using Microsoft Visual C++ tools.”
Once the environment is set in the command prompt, we will compile the program “tkapp.c” by using the namke function, we will type “nmake -f make_basic”. This is going to compile the program and give us the “tkapp.exe” which is our first executable Pro/Toolkit application. Please refer to the command line snapshot below for more details.
Once the environment is set in the command prompt, we will compile the program “tkapp.c” by using the namke function, we will type “nmake -f make_basic”. This is going to compile the program and give us the “tkapp.exe” which is our first executable Pro/Toolkit application. Please refer to the command line snapshot below for more details.
Once the application is ready we will have to just make a protk.dat file to register the application in Pro/ENGINEER. The protk.dat file is a text file which has .dat extension for Pro/ENGINEER to recognize and register the Pro/Toolkit application. I am pasting the contents of the protk.dat file for the above application below:
~~~~~~~~~~~~~~~~~~~~
name tkapp
Startup exe
Allow_stop True
Delay_start False
exec_file tkapp.exe
text_dir .
END
~~~~~~~~~~~~~~~~~~~~
name tkapp
Startup exe
Allow_stop True
Delay_start False
exec_file tkapp.exe
text_dir .
END
~~~~~~~~~~~~~~~~~~~~
For details about the contents of the protk.dat file please refer to PTC guide for Pro/Toolkit (tkuse.pdf). After having the protk.dat file you may launch Pro/ENGINEER from the same directory and get the application running as shown in the snapshot below:
___________________________________________________________________
This is a skeleton application to have us up and running. The subsequent blog entries will deal with more complex features of Pro/Toolkit. I hope that all the readers will be able to follow the steps and complete the application as suggested in this blog. Please feel free to write to me and I will be glad to answer. Do subscribe to this blog and get updates as and when it happens. I will be posting the entries on regular intervals, do leave me a comment; I will be happy to interact with you. In case you require the source code and other files from this application, feel free to write to me at Alxn.Page@gmail.com. Thanks for your valuable time in reading through…. Bye for now, 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.
Were can i find PTC standard make file, Sir?
ReplyDeleteSir, actually i am doing my final dissertation for my masters degree. So as a part of my project i have to create my own profile database, my supervisor told me that can be done using Pro-E Toolkit.
ReplyDeleteBut i am not familiar with languages could you please help me in giving some ideas, plz?
Were can i find this PTC standard make file,Sir?
ReplyDelete