Creating Custom Routines

<< Click to Display Table of Contents >>

Navigation:  User DLLs > Writing DLLs >

Creating Custom Routines

Writing routines to perform a specific function is a capability available in 3DCS.

 

A file (userfunc.cpp) is provided as a base for writing a move, tolerance or measure routine library. This file contains the structure for two moves, two tolerances, and two measure routines. Starting with this file, the user can add his own C code, compile and use the DLL library and routines in the 3DCS software. The file can be edited in any program, however Microsoft Visual C++ can be used to edit, debug and compile the file.

 

To begin, select the Start button / Programs / Microsoft Visual C++ / Microsoft Visual C++.  When in the program select File / Open Workspace.  Find the mtm .dew file and open it.  This will open the userfunc.cpp file.  Determine if your routine is a move, tolerance or measure and add your code in the proper area.  When finished, Select Build at the top toolbar, build (DLL name).  This will list all errors and/or warnings in the bottom window.  If there are no errors, the user-DLL file will have been created under the dcs_exe directory.  Select Build / Execute.  This will launch 3DCS and allow you to test the DLL.  When in 3DCS you must make sure the user-DLL is loaded into the session (See Using Custom Routines in 3DCS). The following code section displays what the userfunc.cpp file initially looks like for a user-DLL move, and where the user should fill in his function code. See Distributed Files for information on the wpMOVECAL_s structure.  

 

/************************************************************/

/* Copyright@2001 Dimensional Control Systems */

/* userfunc.cpp: User-DLL routines */

/* last modified on 2/1/99 */

/************************************************************/

 

// dcs headers

#include "dcs_defn.h"

#include "dcs_ufnc.h"

// user-dll headers

#include "userfunc.h"

 

/************************************************************/

/* Implement your move routines here */

/************************************************************/

// Move1

char dcsMoveName1[] = "userMoveName1"; // user's function name here

char* dcsGetMoveFuncName1() { return dcsMoveName1;}

void userMoveFunc1(dcsDataPtr* pDataPtr)

{

// convert general data pointer to move data pointer

wpMOVECAL_s* pUserMv = (wpMOVECAL_s*)pDataPtr;

// verify that move data pointer is good

if (pUserMv == wpNULL) return;

:

: // user's function code here

:

}