-------------------------------------------------------------------------

The following is sample API code for a template-driven command named 
"!ModHole" that prompts the user to select a hole feature in the active
part and to enter a new diameter for the hole.  The command template 
invokes the function ModHole() defined in this file, which assigns the
new diameter to the specified hole.

---  The following defines command template file ModHole.t ---------------

TEMPLATE=ModHole
description=Modify hole feature.
function=ModHole
no_repeat
opt_form

FIELD=Hole
id=1
class=entity
prompt=Select hole feature.
options=/ftr/,

FIELD=Diameter
id=2
class=distance
prompt=Enter new hole diameter.
trigger

---  The following defines the function export file ModHole.def ----------

LIBRARY ModHole.dll
EXPORTS
ModHoleInit
ModHoleExit
ModHole

---  The following defines program file ModHole.cpp ----------------------

#include "VxApi.h"
#include "stdlib.h"
#include "stdio.h"

/* command function declaration */
int ModHole(int idData);

/*
** You must supply an initialization function whose name
** is the name of your DLL suffixed with "Init" (ModHoleInit).
**
** This function is automatically called by ZW3D when it
** loads your DLL at startup.
**
** It should perform whatever initializations your DLL
** requires, such as registering your callback functions.
**
** The function must be declared with the arguments shown.
**
** The function should return 0 if it is successful; 1 if it fails.
*/

int ModHoleInit(int format, void *data)
{
   vxPath ApiPath;

   /* register your function with ZW3D */
   cvxCmdFunc("ModHole",(void*)ModHole,VX_CODE_GENERAL);

   /* register your command template file */
   cvxPathApiLib("ModHole", ApiPath);
   cvxPathAdd(ApiPath);
   cvxCmdTemplate("ModHole.t");

   return(0);
}

/*
** You must also supply an exit (i.e. cleanup) function whose
** name is the name of your DLL suffixed with "Exit" (ModHoleExit).
**
** This function is automatically called by ZW3D during its
** shutdown (i.e. exit) process.
**
** It should perform whatever cleanup your DLL requires
** before ZW3D is shutdown.
**
** This function should always return 0.
*/

int ModHoleExit(void)
{
   /* put your cleanup code here */

   return(0);
}

/*
** This is the function registered in ModHoleInit().
*/
int ModHole(int idData)
{
   int idHole;
   vxName FtrName;
   svxVariable Dia;

   /* get the name of the user-selected hole feature */
   cvxDataGetEnt(idData, 1, &idHole, NULL);
   cvxEntName(idHole, FtrName);

   /* initialize information to change hole diameter (field 25) */
   cvxMemZero((void*)&Dia,sizeof(Dia));
   sprintf(Dia.Name,"{%s:25}",FtrName);
   cvxDataGetNum(idData, 2, &Dia.Value);

   /* modify hole diameter and regenerate active part */
   cvxPartVarSet(1, &Dia, 0);

   return 0;
}

---------------------------------------------------------------------------

Put ModHole.def and ModHole.cpp in a folder with VxApi.h and zw3dmain.lib.

VxApi.h and zw3dmain.lib are in the "api" folder of the ZW3D installation
in "Program Files".

Build ModHole.dll using something like the following:

   cl.exe /nologo /c /D WIN32 /MT /LD /Z7 ModHole.cpp

   link /DEF:ModHole.def /DLL /OUT:ModHole.dll *.obj zw3dmain.lib

Copy ModHole.dll and ModHole.t to an "apilibs" sub-folder in your ZW3D
user folder: C:\Documents and Settings\All Users\ZWSOFT\ZW3D xxxx\apilibs

Run ZW3D, create a part with holes in it and enter !ModHole in the command
input area.