home - about - advertise     


Pro/TOOLKIT: Setting Up Your Environment in VC++ .NET

By Vojin Jovanović, April 30, 2003

An Application Programmers Interface (API), Pro/TOOLKIT allows Pro/ENGINEER functionality to be augmented and/or customized to meet the specific needs of PTC's customer base using the "C" programming language. Specifically, Pro/TOOLKIT provides the ability to customize the standard Pro/ENGINEER user interface, automate processes involving repetitive steps, integrate proprietary or other external applications with Pro/ENGINEER, develop customized end-user application for model creation, design rule verification and drawing automation.

Unfortunately, Pro/TOOLKIT deservingly gained a reputation of being hard to work with. Such a state of affairs is the result of PTC's current  vision, which dictates where and how this product ought to augment the functionality of Pro/ENGINEER. This vision, as the series of the articles to follow will show, is by no means as "visionary" as toolkit users would hope for; rather, it leaves quite a few features to be desired. In these articles we will explore what it takes to work with this product as well as how one can go beyond what PTC supports today.

A painful reality

New users wanting to learn Pro/TOOLKIT programming too often get discouraged in their first days of struggle. One of the problems that a newcomer is faced with is the setting of the proper development environment so that one can work with Pro/TOOLKIT. The problem is so frequent that someone by now should have done something about it (especially PTC). Unfortunately, to my knowledge, as of today, nobody has.

The development of Pro/TOOLKIT applications does not look so ugly on Unix OS since PTC has adequate support there for toolkit users. But it looks very forbidding on the Windows platform, where PTC's support is minimal and where the normal way of developing applications is with IDE like Visual Studio. Therefore our focus in this article will be dedicated to those new users who often post pleas for help in toolkit user groups related to latter.

First, it is worth mentioning, to make it easier for newcomers, that Pro/TOOLKIT consists of a few libraries: prodevelop.lib ,protoolkit.lib, pt_asynchronous.lib and protk_dll.lib as well as numerous include files. The libraries are precompiled by PTC and sold to the user (for about $20K) with a humongous size of over 2000 function calls. This is quite overwhelming for new users and for that reason PTC provides an API browser and a substantial number of examples that one can re/use for his/her own purpose. However, to work with these examples on the Windows platform is not a simple matter. The difficulty is in the form of nmake files, in which projects are offered by PTC. Even though VC++ supports this way of building modules, this is an archaic way (coming from Unix) of developing projects that lacks all of the benefits contained in GUI of Visual Studio.

We'll look at how one proceeds in setting up a project in VC++ .NET for running a toolkit application within Pro/ENGINEER as well as connecting to it from outside. Both ways have pros and cons and in the end it depends on what you want to achieve.

Setting up a DLL project

We begin with a first project of setting up a Windows DLL application that will get registered with Pro/ENGINEER and will run through a button from Pro/E menus.

Start by creating a new project in VC++ .NET and choose a Win32 application. Enter a name of the project and choose Application Settings (see the required selection below).

Click on image to enlarge

This will give you the empty project into which you can start adding your C/C++ files. Now, the first thing to do, if you already haven't done so, is to enter your Pro/TOOLKIT include and library directories paths. This is done under Tools/Options menu. Observe the paths below for include files ...

Click on image to enlarge

and for the library files ...

Click on image to enlarge

The next thing to deal with is the Project/Properties menu. There are a lot of parameters that Visual Studio allows you to set and that is the single most troublesome source of problems for Pro/TOOLKIT users. Sometimes even more experienced users of Pro/TOOLKIT have problems setting the right switches while trying to create a blank project.

So here we go.

Selecting the Project/Properties menu under C/C++ you'll get the configuration panel (see below). You may accept what is in General by default, while in Optimization just select Disabled (/Od). Now the next selection is Preprocessor as shown below.

Click on image to enlarge

Enter the set of defines as follows:


You'll find these defines in PTC's nmake files and apparently they affect the code generation, so although it's good to have them the project will build even without having them.

The next is the most important selection related to Code Generation. There you need to make a choice regarding the run time libraries. When it comes to DLL's, PTC provides a couple of libraries for linking which are single/multi-threaded; however, when you want to make an exe application you can only make a single-threaded (ML switch, but we'll get to that later). Here, just choose as shown below.

Click on image to enlarge

Other default switches in C/C++ configuration section you may inspect, but they are not as relevant, so you are done here. Now, we go to the Linker section (see below). Under General just choose the name of your output file and then proceed to the Input section. This is the most important section. Here you'll enter the libraries that you want your object files to be linked to. Enter as shown below and you are done.

Click on image to enlarge

Note that a standard libc.lib library is ignored. Often you'll see that when you want to build Toolkit projects, errors such as "already defined .... in libc.lib" or something similar will show up. Now this is a sign that some of the pre-compiled libraries contain symbols that are already defined in Toolkit libraries. In such cases you'll need to ignore some of the standard libraries as was done above. This is a very annoying part of building Pro/TOOLKIT projects, and it should have been handled better by PTC.

That's it. You should be able to be build your project now without any problems.

Setting up an asynchronous application

Now we come to building executable applications that can be used to connect to Pro/ENGINEER and do the job for us externally. This is the road out of the pre-designed development box that PTC would like to keep us in, but luckily they leave an exit door for the bravest, so we need to set up a template project for this kind of business too.

The configuration parameters are almost the same as above except in a couple of places.

First, start a new Win32 application and select it to be a console empty project as shown below.

Click on image to enlarge

Now, add your C/C++ files as usual and proceed to the Project/Properties panel and consider the following.

The three main libraries supplied by PTC that you will use are pre-compiled as single-threaded. This is really a serious limitation for the user because you can't make multi-threaded stand-alone Pro/TOOLKIT applications that can use other multi-threaded libraries (which is the standard today). Therefore you have no choice but to use the C/C++/Code Generation Single-threaded option as we did above. This is something to keep in mind when you experience a lot of errors in linking.

The last thing is to set the toolkit libraries in the Input section of the Linker section of Additional Dependencies (see below). Note again that libc.lib is ignored.

Click on image to enlarge

All other switches in C/C++ and the linker sections are similarly set as in the DLL setup above.

Finally, you can build this project and get an exe file that should run without problems.

Additional help

For those of you who are still having difficulty, consider downloading the two zipped projects below.

The first zip file is a Visual Studio DLL project which is the install test provided by PTC. Extract the files into a directory of your choice (use folder names in the zip archive). Start Visual Studio and open the project. The project assumes that you installed Pro/E 2001 into its default location together with Pro/TOOLKIT, so that C project files will be picked up from that location (of course I can't distribute PTC's C files). If you didn't install Pro/E into its default location you will see an error, and you'll have to add to Source Files these four files: TestError.c TestInstall.c TestRunmode.c and UtilString.c yourself. After building the dll simply register it as an Auxiliary Application in Pro/E via install.dat provided, but don't forget to adjust the path location in install.dat to reflect where the project resides (change PATH_TO_YOUR_LOCATION_OF in install.dat to wherever you unzipped the project). After registering it, to run the applications select the new button -Install Test from the File menu in Pro/E.

The second zip file is my own application example that is a stand-alone executable. Besides providing you with a template exe project it also serves to teach you how to set up a notification business. After building it, just start Pro/E and start the built executable from the Debug directory. The executable will connect to Pro/E and react to your regeneration of models in the session. Study the code to learn more.

This brings us to the end of setting up your environment in VC++ .NET. I hope this explanation makes it easier for new users to start working with Pro/TOOLKIT and relieves some of the frustrations most people initially experience with this product.

About the Author

Vojin Jovanović is an independent consultant with 5 years of experience developing Pro/TOOLKIT applications in the area of design optimization and automation as well as over 10 years of experience in developing scientific numerical applications. He has published in international journals and presented at various conferences. His area of expertise is in computational geometry related to MCAD and in development of financial applications. You can reach him at fractal97@hotmail.com and visit his website at: <http://www.purplerose.biz/Vin>.

Related Articles

CADdigest Weekly
Email (required) *

A week's worth of articles will be emailed to you. See latest issue .