HOWTO: Example Pro/Toolkit Application using Visual Studio 2005
In my previous post titled "Example ProTookit Application using Visual Studio 2005" I received a comment asking to explain how I created the sample workspace (Pro/Toolkit Application using Visual C++ 2005) which can be downloaded by clicking the file below:

http://ossandcad.googlecode.com/files/ProToolkitVisualCpp.zip
I should point out that the workspace that is attached above, while it is currently in Visual Studio 2005 format, came initially from Visual Studio 2002 (or known as Visual Studio.NET) and my colleagues and I regularly updated the workspace in current versions of Visual Studio.
In this post I try and explain the steps I used to create a sample workspace from scratch in Visual Studio 2005 for Pro/Toolkit applications. For more details (although with some mistakes some of which I will list in future posts) refer to "tkuse.pdf" in "C:\Program Files\proeWildfire 3.0\protoolkit".
I break the process down into following steps:
Creating the Visual Studio 2005 solution
The easiest method I know of to create a Pro/Toolkit Application in Visual Studio 2005 (that matches the above workspace) is to start with an Empty Project. Name it "proe" for example.
Add a file named "main.cpp".
Add the following code to "main.cpp"
#include <windows.h>Change the "Configuration Type" to "Dynamic Library (.dll)".
#include <protoolkit.h>
#include <procore.h>
/** Make sure to call ProToolkitMain passing the arguments passed into main
*/
extern "C" int main(int argc, char **argv)
{
ProToolkitMain(argc, argv);
return 0;
}
/** Required entry point for Pro/Toolkit
*/
extern "C" int user_initialize()
{
MessageBox(NULL, "Pro/Toolkit App", "proe", MB_OK);
return 0;
}
extern "C" void user_terminate()
{
return;
}
Add the relevant include folders for Pro/Toolkit ("C:\Program Files\proeWildfire 3.0\protoolkit\includes";"C:\Program Files\proeWildfire 3.0\prodevelop\includes").
Add the following pre-processor definitions (WIN32;NDEBUG;_WINDOWS;_USRDLL;PROE_PROJ_EXPORTS;PRO_MACHINE=29; PRO_OS=4;hypot=_hypot;MSB_LEFT;far=ptc_far;huge=p_huge;near=p_near;_X86_=1)
Make sure for the Runtime Library you are using "Multi-threaded DLL (/MD)" or the "Multi-threaded Debug DLL (/MDd)" based on whether you are using "Release" or "Debug" configuration respectively.
Make sure that the "Treat wchar_t as Built-in Type" is set to "No (/Zc:wchar_t-)".
Add the relevant Pro/Toolkit and Pro/Develop library folders ("C:\Program Files\proeWildfire 3.0\prodevelop\i486_nt\obj";"C:\Program Files\proeWildfire 3.0\protoolkit\i486_nt\obj").
Add the "Additional Dependencies" (wsock32.lib mpr.lib prodev_dllmd.lib protk_dllmd.lib psapi.lib)
Do a Rebuild and make sure you have a DLL named "proe.dll" in a sub-folder named Debug or Release depending on your build configuration.Creating the Pro/Toolkit application files and message files
Pro/Engineer loads Pro/Toolkit applications using a registration file named "protk.dat" in the Debug AND Release folder. You need to create a protk.dat file for the Pro/Toolkit DLL that you created using the workspace above. While developing and testing the Pro/Toolkit application I use the following "protk.dat":
NAME proe
EXEC_FILE proe1.dll
TEXT_DIR ..\text
STARTUP DLL
allow_stop TRUE
revision Wildfire
END
The "protk.dat" is pretty easy to understand although it would have helped if Pro/Engineer used a more standard method such as the Windows Registry (although that may not work since Pro/Engineer is multi-platform). The main variables you need to be aware of are:
- TEXT_DIR - The value for this variable is "..\text". This means you need to create a sub-folder named "text" under your main folder. In the "text" folder create a text file named "menu.txt". The "text" folder and the text file "menu.txt" (the name can be changed but I don't delve into that in this post) are Pro/Engineer's bizarre method to enable localization. The "menu.txt" file looks something like the following:
USER %0sIt simply lists the label that is seen by the Pro/Toolkit application and its corresponding value. Most Visual C++ developers use either a String Table or other sort of Resource. If you think this is weird, I think it may have something to do with Pro/Engineer supporting multiple Operating Systems.
%0s
#
#
MenuLabel
Menu
#
#
PushButton
PushButton
#
#
- STARTUP - For the example provided the type is "DLL".
While developing and testing your Pro/Toolkit application I use the following method:
- Create a shortcut to "C:\Program Files\proeWildfire 3.0\bin\proe.exe" in your Pro/Toolkit's "Debug" or "Release" folder.
- Make sure the "Start in" text box for this shortcut remains empty which means that this shortcut will start Pro/Engineer in the current folder and will automatically load the DLL specified in protk.dat located in the same folder.
- Double click the shortcut you created to run Pro/Engineer. If you get a message box with the text "Pro/Toolkit App" then IT WORKED. REJOICE.

If the method in the above post did not work for you, you can also download the ZIP file I have provided and try that out. If you need more help, post a comment and I will try to provide more information.
27 comments:
I created a workspace as you told us step by step, but when I builded it,a command line error appeared: missing source filename.
Could you explain it for me ?
Thanks a lot !
I did a quick search for the error that you received and found this:
http://msdn2.microsoft.com/en-us/library/aa983368(VS.80).aspx
It seems to indicate that the "mail.cpp" file that you need to add per my instructions is not being picked up by Visual Studio 2005 compiler. See if it got added properly. As an alternate download the zip file I have posted to use as a starting point.
Sorry, my previous comment should have read "main.cpp" not "mail.cpp". Please ensure that "main.cpp" is added properly to the Visual Studio 2005 solution.
Thanks for your help, Ganeshram Iyer.
I have found where the proble is.
There is something strange(not wrong)with the content of pre-processor definitions: when I copy the content and paste it into Visual Studio 2005, there will be a ' " 'before the content(I still can't understand).If I delete the '" ',the workspace will be builded successfully.
I an a chinese engineer. Would you mind knowing a chinese friend?
You can write to my E-Mail:tianxiaotao.cw@163.com.cn
Glad to hear that it went well. If it would not be too much trouble, I would love to know what you use the Pro/Toolkit application for and if and how my tutorial helped.
The company that I have worked for uses AutoCAD as the platform. I want to replace the platform with Pro/Engineer, but there is something different between the ISO standard and our national standard. So we need to customise it.
I have been looking for the tutorial for a long time. Even I have found some websites but they are not what I need. Because I use Visual Studio 2005 and Pro/E Wildfire 4.0. Their tutorials discrible the settings in old versions and very simply, even it doesn't go well.
Thanks again for posting. I hope you are tianxiaotao.cw@163.com.cn. I tried to email you but the email bounced back.
If you found this tutorial helpful do let me know if I can post other Pro/Toolkit-related contents.
I am sorry that I have put a chinese domain behind my E-Mail address.
You can try the following again:
tianxiaotao.cw@163.com
Do you have any tutorials about using the MFC dialogue to exchange datas with Pro/E for developping Pro/Toolkit application?
Thanks again!
Thanks for the comment. As far as a MFC dialog tutorial for Pro/Toolkit App - I don't have a tutorial but do have a full fledged app at the company I work with that I can strip to create one. But I must say that working with MFC dialogs and Pro/Toolkit is nothing special. It is a regular MFC dialog app (possibly in a DLL) that can be loaded into the Pro/Toolkit app. Is there any special aspect of the MFC+Pro/Toolkit app that you are looking for help on? I could generate a tutorial for simply that aspect then.
I am interested in finding a developer to develope a screen room drawing app for me to use on my web site, I would like to talk with a developer or two on this
Hello Jim, Glad to know you found my blog. I would like to hear your requirements on the "screen drawing app". Post a comment or you could even email me at ganeshramiyer at gmail dot com.
Thank you for every think. Its so usefull.
Mustafa TURGUT, TURKEY
Hi Mustafa,
Thanks for comment but please do let me know more - what articles do you want to read in the future on my blog?
Hi,
I ma very new to Pro/Toolkit. I have done some automation work using the relations and parameters in Pro-E. Now i want to learn Toolkit, please let me know what are the system environmental variables should i set?
Hello Anonymous,
To be honest I don't quite understand your question. If you are asking if I set any environment variables on my Windows PC then the answer is "I did not set any env var".
But when I do see my env var dialog box I see only the following under "User variables for %USERNAME%"
Variable name: PRO_COMM_MSG_EXE
Variable value: "C:\Program Files\proeWildfire 3.0\i486_nt\obj\pro_comm_msg.exe"
though I am not sure if this is something you even need to set. If you tried to work with the article/downloadable workspace I have provided and it did not work, then I can try to help more. Post a comment with specific questions which I can answer.
Hi!
Nice blog,
im new to toolkit and tried to build your project on vs 2008 express.
When i try to run the dll on wf2 win64 i got the message:
The Pro/TOOLKIT application "ProE_Proj" was not unlocked before distribution to your site.
se Pleasec ontact the provider of "ProE_Proj" for assistance.
What is wrong? can you help?THX
cheers
Hi Hans,
Thanks for the comment. I guess I should post a quick article on the fact that I am delivering projects purely for developers. I don't pay for a personal license of Pro/Engineer + Pro/Toolkit. That means that anyone who wants to load my Pro/Toolkit application in their Pro/E NEEDS to have an active Pro/Toolkit License.
So the error you have indicates that you do not have a Pro/Toolkit license. Sorry about that.
Hi,
i make the example project, but i receive the linker error:
main.obj : error LNK2019: unresolved external symbol _ProToolkitMain referenced in function _main
I used a x64 pc.
Thanks,
Vincenzo.
Thanks CattoCrociato for your comment. Unfortunately I do not have access to an x64 PC to test what happens on that platform with my workspace. There are numerous things I am unaware of viz. how well is Pro/Toolkit supported on x64? are there any nomenclature/functional differences between various API? etc.
If you do find a solution, I would appreciate it if you could post it with your next comments, so readers would be able to use it.
Dear Ganeshram Iyer,
First thanks for your very accurate toolkit "tutorials". Owing to your help I have succesfully finished an add-on for our company. Now we want to do a repetative operation on numerous files with pro toolkit and Distributed ProBatch. I followed the toolkit guide instructions for task based library but dbatch fails to load the dll fuction. Do you have experience? How should the dbatchs.dat file look like?
Thanks again!
Ganeshram Iyer
thanks so much!
the tutoriol help me in my study!
Thanks for the comment Hankster,
I must apologize as I have no experience with ProBatch. I use an alternate technique to run Pro/E in batch mode - detailed here: http://ossandcad.blogspot.com/2008/04/batch-mode-proengineer.html.
This may not suit your needs but unfortunately I may not be more help.
Thanks whatit for the comment. Glad to be of assistance.
Hi,
Your tutorial was very useful while setting up new ProToolkit Project.
Thanks a lot, keep writing
Sandip
Thanks Sandip Jadhav for your comment. Let me know if there are any topics you would like to read about.
hi,
I am compiling pro/toolkit application code for Wildfire4.0 in visual studio2005.I use the makefiles for compiling the code. But I do get some errors (Linking errors)
somehow I tried with new visual studio set up and got the DLL but that DLL is not working .
So I am trying with the make file concept(provided by PTC ), because I suppose that the set up done by me may not be correct.They have done some set up there for Visual Studio 2005.
But I solved most fo the errors and still I have some errors to fix it now.
could anyone help on this?
(I believe in this makefile concept , because I got a DLL and it works fine- without any errors).
Error 215 error LNK2019: unresolved external symbol _user_terminate referenced in function _user_terminate_plus
Error 216 fatal error LNK1120: 1 unresolved externals
Error 217 fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 8\VC\bin\link.EXE"' : return code '0x460'
Error 218 error PRJ0019: A tool returned an error code from "Performing Makefile project actions"
I thank you all guys who helped me before for their valuable help.
Hey selva,
Thanks for the comment. Did you download the zip file I have posted with this blog and at http://ossandcad.googlecode.com/files/ProToolkitVisualCpp.zip.
I believe this should work for Pro/E WF 4.0 too. I have not tested that yet but will do so in a few days as I plan to upgrade to Pro/E WF 4.0. If I notice any differences, I will post a new version on my blog. Keep following my blog for any updates.
If you have a license issue then my colleague at http://cadinterface.blogspot.com/2009/05/unlocking-protoolkit-application.html has posted a solution.
Post a Comment