Anda di halaman 1dari 77

Go to CGTech Help Library

VERICUT Development Tools


VERICUT Development Tools

OptiPath API

Introduction
OptiPath API is designed to enable an interface between VERICUT and customized plug-
in toolpath optimization programs. OptiPath API is only available on Windows platform.
When a system environment variable "CGTECH_OPAPI" is defined with a user's
optimization library name, VERICUT will automatically run OptiPath in API mode and
connect to user's program. VERICUT's own OptiPath function will no longer be
available.
NOTE: The files (opapi.lib, opapi_template.c, optiapi.h and optimport.h) referred to
below, are all located the \windows\optipath_api\ folder of your VERICUT software
installation.

How to build a plug-in library


The plug-in format used by VERICUT is a "WIN32 Dynamic Linked Library" which can
be built using MSVC. The following files/libraries are needed:
opapi.h, optimport.h, opapi.lib, opapi.dll
and a sample C file called "opapi_template.c"
The easiest way to build such a plug-in dll , for example, "opapi_usr.dll", is to start with
creating a C/C++ file, like "opapi_usr.c", with the skeleton code found in
"opapi_template.c".
There is one setup function must be present with exactly the declaration style and name
provided below:
void opapi_setup(void);
where optimization callback functions must be registered inside this setup function.
The following functions can be used to register these callbacks in setup:
void opapi_set_initialize_function(OPAPI_InitializeFunction);
void opapi_set_optimize_function(OPAPI_OptimizeFunction);
void opapi_set_terminate_function(OPAPI_TerminateFunction);
void opapi_set_tool_change_setup_function(OPAI_ToolSetupFunction);
void opapi_set_user_data(void *);

In addition, there are 25 optional utility functions that provide the user program with
detailed process data. All the functions are described in the Function Definition section at
the end of this document. Examples can be found in "opapi_template.c".

1
VERICUT Development Tools

char *opapi_get_variable_value(char *);

double opapi_get_axial_depth(void);
double opapi_get_program_feedrate(void);
double opapi_get_spindle_speed(void);
double opapi_get_total_distance(void);
double opapi_get_total_time(void);
double opapi_get_total_volume_removed(void);
double opapi_get_volume_removed(void);

int opapi_get_conventional_cut_flag(void);
int opapi_get_side_cut_flag(void);
int opapi_get_thin_cut_flag(void);

void opapi_free(char *);


void opapi_get_contact_area(int *, double *);
void opapi_get_current_tool(char **, int *, sOPAPI_APT_CUTTER *);
void opapi_get_cut_machine_position(double[12], double[12]);
void opapi_get_cut_tool_position(double[6], double[6]);
void opapi_get_decompressed_map_data(sOPAPI_MAP, int *, char **);
void opapi_get_grid_map(sOPAPI_MAP *);
void opapi_get_motion_type(eOPAPI_MOTION_TYPE *, double[6]);
void opapi_get_radial_width(void);
void opapi_get_toolpath_record(int *, char **);
void opapi_send_message(char *, int);
void opapi_set_override_rpm(double);
void opapi_set_resolution(double);
void opapi_write_out_comment_line(char *);

Include "opapi.h" and "optimport.h" in "opapi_usr.c". Compile and link all the usr files
with "opapi.lib". This will generate a ".dll" library.

2
VERICUT Development Tools

Set system environment variable "CGTECH_OPAPI" set to where this dll is , for
example, "c:\opapi\opapi_usr.dll" and place "opapi.dll" in the same directory where
"CGTech.dll" is. OptiPath API mode is now ready to go.

3
VERICUT Development Tools

Function Definitions
Setup Functions

void opapi_setup(void)
Setup function. Must be present with exactly the same declaration style and name. Called
when OptiPath API library is first loaded. It is to register user's optimization function.
The following functions can be and should only be called in this setup function:
opapi_set_initialize_function(OPAPI_InitializeFunction);
opapi_set_optimize_function(OPAPI_OptimizeFunction);
opapi_set_terminate_function(OPAPI_TerminateFunction);
opapi_set_tool_change_setup_function(OPAI_ToolSetupFunction);
opapi_set_user_data(void *);

void opapi_set_initialize_function(OPAPI_InitializeFunction func_p)


Register user's initialization function with VERICUT. The initialization function
registered, func_p, should have the following declaration style:
typedef int (*OPAPI_InitializeFunction)(void *userData);
which returns 1 if initialization is successful or 0 if initialization failed. If failed, OptiPath
will be turned off. This function should only be called in opapi_setup() function. Once
registered, the initialization function, func_p, will be called each time the user turn
OptiPath on.

void opapi_set_optimize_function(OPAPI_OptimizeFunction func_p)


Register user's optimization function with VERICUT. The optimization function
registered, func_p, should have the following declaration style:
typedef void (*OPAPI_OptimizeFunction)(void *userData);
This function should only be called in opapi_setup() function. Once registered, the
optimization function, func_p, will be called in a frequency defined by user (see
opapi_set_resolution(double)) during cutting process.

4
VERICUT Development Tools

void opapi_set_terminate_function(OPAPI_TerminateFunction func_p)


Register user's terminate function with VERICUT. The termination function registered,
func_p, should have the following declaration style:
typedef void (*OPAPI_TerminateFunction)(void *userData);
This function should only be called in opapi_setup() function. Once registered, the
termination function, func_p, will be called each time OptiPath is turned off.

void opapi_set_tool_change_setup_function(OPAPI_ToolSetupFunction
func_p)
Register user's tool change setup function with VERICUT. The tool change function
registered, func_p, should have the following declaration style:
typedef int (*OPAPI_ToolSetupFunction)(void *userData);
which returns 1 if tool setup is successful or 0 if tool setup failed. If failed, no
optimization will occur for the current tool. Therefore, if a tool does not need to be
optimized, just return 0 when func_p is called for this tool. This function should only be
called in opapi_setup() function. Once registered, the tool setup function, func_p, will be
called each time a tool change occurs.

void opapi_set_user_data(void *usr_data)


Set user data that needs to be passed among optimization functions
OPAPI_InitializeFunction, OPAPI_ToolSetupFunction, OPAPI_OptimizeFunction,
OPAPI_TerminateFunction. This function should only be called in opapi_setup()
function.

5
VERICUT Development Tools

Utility Functions

char opapi_get_variable_value(char * variable_name)


Return a variable value. Only valid for G-code toolpath files.

Parameters:
variable_name : Input, name of the variable.
Return the address of variable value depending the variable type.
If variable is a number, return the address of the double value (double *).
If variable is a text, return the address of the string (char *)

double opapi_get_axial_depth(void)
Return maximum axial depth.

double opapi_get_program_feedrate(void)
Return programmed feedrate.

double opapi_get_radial_width(void)
Return maximum radial width.

double opapi_get_spindle_speed(void)
Return spindle speed in rpm.

double opapi_get_total_distance(void)
Return total distance.

double opapi_get_total_time(void)
Return total time.

6
VERICUT Development Tools

double opapi_get_total_volume_removed(void)
Return total volume of material being removed.

double opapi_get_volume_removed(void)
Return the volume of material being removed by the current motion.

int opapi_get_conventional_cut_flag(void)
Return conventional cut flag.

int opapi_get_side_cut_flag(void)
Return side cut flag.

int opapi_get_thin_cut_flag(void)
Return thin cut flag.

typedef struct s_OPAPI_CUTTER

{
double cutterDiameter;/* Cutter diameter, D */
double cutterHeight;/* Cutter height, H */
double cornerRadius; /* Corner radius, R */
double eDistance;/* Distance from tool centerline to corner radius center, E */
double fDistance;/* Distance from tool tip to corner radius center, F */
double baseAngle;/* Base angle, A */
double sideAngle;/* Side angle, B */
} sOPAPI_CUTTER;

7
VERICUT Development Tools

typedef struct s_OPAPI_MAP

{
double toolEnd[2]; /* Tool tip at starting position projected to the projection grids, in
gridAxisX, gridAxisY */
double gridOrigin[3]; /* Origin of projection grids in X, Y, Z */
double gridAxisX[3];/* Projection grids' X axis in I, J, K. X axis in normal to the Z axis
and tool axis in starting position */
double gridAxisY[3]; /* Projection grids' Y axis in I, J, K */
double gridAxisZ[3]; /* Projection grids' Z axis in I, J, K. Z axis is the unit vector of
cutter translation position vector */
double gridSize; /* Length of each grid */
int numGridsX;/* Number of grids along gridAxisX */
int numGridsY;/* Number of grids along gridAxisY */
int maskSize; /* Number of int/32 bits that are used to store the mask */
int *gridMask; /* Pointer to grid mask */
} sOPAPI_MAP;

typedef enum e_OPAPI_MOTION_TYPE

{
OPAPI_LINEAR = 0,
OPAPI_CIRCLE = 1,
OPAPI_NURBS = 2,
OPAPI_RAPID= 3,
}eOPAPI_MOTION_TYPE;

8
VERICUT Development Tools

void opapi_free(char *data)


Free memory.

Parameters:
data : Input, memory pointer.

void opapi_get_contact_area(int *contact, double *area)


Get the area that tool is in contact with material

Parameters:
contact : Output, 1 if tool is in contact with material, 0 if not.
area : Output, area of material that is in contact with the tool.

void opapi_get_current_tool(char **tool_id, int *is_apt,


OPAPI_APT_CUTTER *apt_cutter)
Get the current tool information. This function can be called in
OPAPI_ToolSetupFunction, to retrieve information about the current loaded tool.

Parameters:
tool_id : Output, tool id of current tool as defined in tool library. Will be null if an apt
tool is defined by cutter statement.
is_apt : Output, 1 if an apt cutter, 0 if not.
apt_cutter : Output, cutter definition stored in sOPAPI_CUTTER if current tool is an apt
cutter.

void opapi_get_cut_machine_position(double start[12], double end[12])


Get machine positions at the starting and ending points of current motion.

Parameters:
start : Output, machine starting position in (X, Y, Z, U, V, W, A, B, C, A2, B2, C2)
end : Output, machine ending position in (X, Y, Z, U, V, W, A, B, C, A2, B2, C2)

9
VERICUT Development Tools

void opapi_get_cut_tool_position(double start[6], double end[6])


Get tool positions at the starting and ending points of current motion. The start/end
positions are relative to the "stock" component's coordinate system.

Parameters:
start : Output, tool starting position, defined by tool tip position [0-2] in (X, Y, Z) and
tool axis vector [3-5] in (I, J, K).
end : Output, tool ending position, defined by tool tip position [0-2] in (X, Y, Z) and tool
axis vector [3-5] in (I, J, K).

void opapi_get_decompressed_map_data(sOPAPI_MAP *map, int


*size, char **values)
Transform immersion data to the form of an array of integers, decompressed by
gridMask. Each array element has a value of 0 or 1. For example, values[numX] = 0
means on the [numX]th grid (row = 1, column = 0), the cutter has no contact with
material.

Parameters:
map : Input, a map structure that contains grid mask data.
size : Output, size of the unsigned array.
values : Output, pointer to the bit array. Must be freed by using opapi_free(char *).

void opapi_get_grid_map(sOPAPI_MAP * map)


Get detailed tool-material immersion data.

Parameters:
map: Output, returned map->gridMask field must be freed by using opapi_free(char *).
VERICUT provides kinematics of cutter immersion data in the form of a grid map, a
mapping of what parts of the workpiece are in contact with the cuter and stores it in the
sOPAPI_MAP structure. The grid map is a projection plane (gridAxisX & gridAxisY)
that is normal to cutter transition vector (gridAxisZ). Each grid has a bit value of 1 or 0,
with 1 meaning the projected part on the workpiece is in contact with the cutter and 0
meaning no contact. All the grid bits are stored row by row, starting from bottom to top,
left to right, into (a) 32-bits integer(s).

10
VERICUT Development Tools

void opapi_get_motion_type(eOPAPI_MOTION_TYPE *type, double


circle[6])
Get current motion type.

Parameters:
type : Output, motion type defined in eOPAPI_MOTION_TYPE
circle : Output, circle defined by circle center [0-2] in (X, Y, Z) and circle normal [3-5]
in (I, J, K) for circular motion.

void opapi_get_toolpath_record(int *rec_num, char **record)


Get the current toolpath record.

Parameters:
rec_num : Output, current record number(line number) in toolpath file.
record : Output, current toolpath record being processed.

void opapi_send_message(char *message, int display)


Send a message to VERICUT.

Parameters:
message : Input, message to be sent
display : Input, 0 written to log file; 1 displayed in logger; 2 display in logger and written
to log file.

void opapi_set_override_rpm(double rpm)


Set override spindle speed in rpm. This function should only be called in
OPAPI_ToolSetupFunction, which sets up a new spindle speed for the tool just loaded.

Parameters:
rpm : Input, spindle speed in rpm.

void opapi_set_resolution(double distance)


Set optimization resolution distance. Optimization resolution distance controls the
frequency or "sampling distance" used to analyze each tool path motion. Each feed rate
controlled motion is partitioned into samples and OPAPI_OptimizeFunction is called

11
VERICUT Development Tools

based on this distance. Distance is measured along the tool motion. This function should
only be called in the OPAPI_InitializeFunction.
If the user program does not set up a resolution by calling this function in initialization, a
default resolution distance based on the size of the cutting tool relative to the displayed
model is calculated by VERICUT. This choice is recommended when little or no
knowledge of cutting methods or feed rates is available.

Parameters:
distance : Input, optimization distance.

void opapi_write_out_comment_line(char *comments)


Write out a comment line in the optimized toolpath file. Only valid in G-code toolpath
file.
Parameters:
comments : Input, comment line to write out. Must be a complete line, including starting
comment character and end of line return character.

12
VERICUT Development Tools

API Interface for Heidenhain iTNC Controller

This document describes the VERICUT 6.1 requirements for the Heidenhain iTNC API.
The API functions in this document are the minimum frame work needed for VERICUT
and the Heidenhain iTNC Controller to perform a successful simulation. The API
functions may and will be modified to take advantage of new and existing capabilities of
the Heidenhain iTNC Controller and new API functions will be implemented as needed.
The API functions must be implemented and exportable via the TNC DLL.

The API functions will isolate VERICUT from Heidenhain iTNC specific nuances as
much as possible. For example, TNC circle data is given as a set of intermediate points
on the circle. The TNC DLL must buffer up the intermediate points and then create the
circle data based on the buffered intermediate points. VERICUT does not want the
intermediate points. VERICUT wants just the resultant circle motion.

A new NC program type has been added to VERICUT 6.1. The new type is located in the
NC Program window:
Project menu > NC Programs
NC Program Type = Heidenhain iTNC

Set the following environment variable so that VERICUT will find the new TNC DLL:

set CGTECH_TNCAPI_NEW="path to TNC dll"

The API function, ctlapi_get_next_record_TNC(…), uses the structure sCTL_MOTION


found in "ctlapi.h"

The log file debug feature can be turned On/Off using the Debug Control API option on
the Process Options window: Debug tab (Project > Processing Options > G-Code >
Process Options).

The rest of this document defines the TNC API function prototypes which must be
implemented and exportable via the TNC DLL.

13
VERICUT Development Tools

/*********************************************************
This function shall initialize the COM interface, establish connection to the TNC and
initialize session variables.
Returns:
0, Error
1, OK

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

int ctlapi_hard_initialize_TNC(void);

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

This function shall perform a TNC disconnect, un-initialize the COM interface and reset
session variables.

Returns:
0, Error
1, OK

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

int ctlapi_hard_terminate_TNC(void);

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

This function shall set the main program file, set tool position, set feed rate and set
execution mode. This function will be called for initial setting of main program file, for
main program file change and at simulation reset.

(I) program, main program file

14
VERICUT Development Tools

Returns:
0, Error
1, OK

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

int ctlapi_program_prepare_TNC(char *program);

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

This function shall start the execution of the selected main program file.

Returns:
0, Error
1, OK

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

int ctlapi_start_program_TNC(void);

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

This function shall stop execution of the main program file.

Returns:
0, Error
1, OK

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

15
VERICUT Development Tools

int ctlapi_stop_program_TNC(void);

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

This function shall get the list of motions created from one record.

(O) list, list of motions created from one record.

Returns:
number of motions (int)

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

int ctlapi_get_next_record_TNC(sCTL_MOTION **list);

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

This function shall open the tool file for write. The tool file should be located in the same
directory as the Main Program File (MPF). Extract the path from the specified MPF and
construct the tool file (path and name.)

(I) mpf, main program file

Returns:
0, Error
1, OK

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

int ctlapi_frame_initialize_TNC(char *mpf);

16
VERICUT Development Tools

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

This function shall close the tool file and send a request to the controller to load the tool
file.

Returns:
0, Error
1, OK

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

int ctlapi_frame_terminate_TNC(void);

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

This function shall write tool info to the tool file for a single tool.

(I) tool_num, tool number


(I) radius, tool radius
(I) length, tool length

Returns:
0, Error
1, OK

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

int ctlapi_frame_tool_TNC(int tool_num, double radius, double length);

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

17
VERICUT Development Tools

This function shall return the current controller simulation time.

Returns:
time (double)

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

double ctlapi_get_time_TNC(void);

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

This function shall return the program-at-end flag.

Returns:
0, not at end of program
1, at end of program

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

int ctlapi_get_prog_at_end_TNC(void);

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

This function shall set the event notify function.

The event notify function shall notify VERICUT of one of the following events:

0 = program block
1 = tool change
2 = enter subroutine

18
VERICUT Development Tools

3 = leave subroutine
4 = current program line
5 = S word
6 = F word
7 = M word
8 = current message

The event notify function prototype is:

void event_notify(int event_type, long line_number, char *event_text);

Returns:
none

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

void ctlapi_set_event_notify_function_TNC(void (*func)(int, long, char *));

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

This function shall set the client message function.

The client message function allows the controller to pass text messages to VERICUT.

The client message function prototype is:

void client_message(char *message);

(I) func, client message function.

Returns:
none

19
VERICUT Development Tools

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

void ctlapi_set_client_message_function_TNC(void (*func)(char *));

20
VERICUT Development Tools

CME-API

Introduction

CME-API is the replacement for VERICUT Machine Developers Kit (DevKit). DevKit
consisted of a licensed compiler and documentation on how to create and compile
CGTech Macro Language (CML) programs. CML programs enabled the user to extend
VERICUT's control emulation with custom NC macros that emulate unique behavior of
the customer's machine. The CML program has access to specific "exported" functions
within VERICUT. The compiler produced a CGTech Macro Executable (CME) file
containing a compiled form of the CML program. The CME was then used by
VERICUT's control file to add customer-created NC macros to the control emulation.
The DevKit functionality is replaced by a new method for creating custom NC macros:
the C Macro Extension – Application Programming Interface, or CME–API.
Using CME-API, you can write a standard C, or C++, program which calls "exported"
functions in VERICUT (the exact same "exported" functions that were available to a
DevKit CML program). He then compiles this program using Microsoft's Visual Studio
6.0 C++ compiler, into a standard Windows Dynamic Link Library (DLL). The DLL is
loaded by VERICUT at runtime, extending VERICUT's control emulation with custom
NC macros (exactly the same as a DevKit-created CME).
CME-API replacement has several advantages over DevKit:
• CME-API uses an industry-standard language: C or C++
• CME-API gives the developer access to all the full, rich features of C and C++
• CME-API enables the developer to use standard C, and C++, debugging tools
• CME-API runs much faster than a CME file

The CME-API functionality is available with a base Verification license, not as an


optional module. Any VERICUT user has access to it, but it does require using Microsoft
Visual Studio 6.0 C++. CME-API is available only on Windows. There are no plans to
port it to UNIX.

CME-API Documentation
This document is intended to describe using "exported" VERICUT functions in a C
program, compiling a CME-API DLL in Microsoft Visual Studio, and how to use the
DLL in a VERICUT simulation. It will also contain a document on how to convert a
CML program to C.

21
VERICUT Development Tools

This documentation is written for use by a software developer with a working knowledge
of the C programming language and Microsoft Visual Studio. It is not intended to
document the C programming language, nor how to use Microsoft's development
environment. There are many fine books available on both these topics in libraries and
book stores. There are also many college and university courses on the C and C++
programming languages.

CME-API Deliverable
The CME-API deliverable consists of an example C source file ( example1.c ), a library (
( CGTech.lib ) , and header files ( cmeapi_defines.h, cmeapi_import.h, and
cmeapi_types.h ) that provide access to available "exported" functions These files can all
be found in the \windows\cmeapi\ directory of your VERICUT installation.

Migration from DevKit to CME-API


Former DevKit users must modify their existing CML programs in order to create a new
CME-API compatible DLL. They will have to convert their CML programs to C, and
compile them using Microsoft's Visual Studio 6.0 C++ compiler. Fortunately the old
CML language syntax is very similar to C. All the VERICUT functions used by CME-
API are exactly the same as those that were available to CML. End-users of CME-API
must be an experienced C, or C++, programmer with sufficient knowledge of the C
language syntax and the Microsoft Visual Studio development environment.

22
VERICUT Development Tools

Convert a CMS file to C using the CME-API


This section describes the steps that are required to convert an existing DevKit CMS file
to a C file that can be used with CME-API.

1. Change "text" to "char *", or "char [ ]".


2. Change "number" to "double"
3. Change functions starting with "cfunc_" to start with "cmeapi_".
4. Change function declarations to ANSI C declarations.
5. Move locals variables inside the function.
6. Change "AXIS" to "CMEAPI_AXIS".
7. Change prefix "RP2_" to "CMEAPI_ ". For example, RP2_POINT should be
changed to CMEAPI_POINT.
8. Change expressions, i.e. from lt to <.
9. Change string expressions to use C string functions
10. Add "CMEAPI_" in front of some previous #defines
11. Use the function cmeapi_register_macro( ) to define macros in VERICUT
instead of the name beginning with "cms_".
12. Define a function called cmeapi_init( ).

/* ************************************************************************** */
#define DllExport _declspec(dllexport)

/* ************************************************************************** */
DllExport void cmeapi_init(void)

{
printf("cmeapi_init() Success!\n");
cmeapi_register_macro("UserCheckSpindle", cms_UserCheckSpindle);
}

23
VERICUT Development Tools

Build a DLL in Visual Studio Express C++

This section describes how to build a DLL in Visual Studio Express C++.

To build a DLL in Visual C++:


• Start a New Workspace/Project for an Empty DLL
• Add WIN_NT to the C/C++ preprocessor definitions
• Add CGTech.lib to Link library modules
• Add the C source code and header file, compile, & link

The following are the steps to required to configure Visual Studio Express C++ to work
with the VERICUT CME-API, and to build the example included with VERICUT.

1. Launch Visual Studio Express > New > Project


• General > Empty Project
• Give the project a name – (e.g. vericut_cme)
• Store project on local drive – (e.g. c:\vericut_cme)

2. Locate the Tree on the left


• Right Click on the Top Level [vericut_cme] > Add > Existing Item
• Navigate to your VERICUT directory - (e.g. c:\cgtech612\windows\cmeapi)
• Highlight all files > Click Add

3. Locate the Tree on the left


• Right Click on the Top Level [vericut_cme] > Properties
• Configuration Properties > General > Configuration Type > [Dynamic Library
(.dll)]
• C/C++ > Preprocessor > Preprocessor Definitions > [WIN_NT]
• Linker > General > Additional Library Directories
[c:\cgtech612\windows\cmeapi]
• Linker > Input > Additional Dependencies > CGTech.lib

4. Click OK to save properties

24
VERICUT Development Tools

5. Top Menu > Build > Build Solution


• Results should be [Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped]

6. Launch VERICUT
• Top Menu > Configuration > Adv. Options > Dev Kit CME [tab] > Browse to
where the vericut_cme.dll was outputted (e.g. c:\vericut_cme\vericut_cme\debug\
vericut_cme.dll) > Click OK.

7. To confirm the DLL is being loaded, modify your vericut.bat file before launching
VERICUT.
• Change "%CGTECH_JRE%\bin\javaw" to "%CGTECH_JRE%\bin\java"
(remove the "w") so that the dialog window stays open.

If the DLL is loaded successfully, you should see "cmeapi_init() Success!"

25
VERICUT Development Tools

Registering Functions
Suppose you defined a function char *modify_input_str(char *) in C. The CME-API does
not know about it until you notify the CME-API by "registering" it. The function does not
have to be named modify_input_str, it can be named anything that you want, but it does
have to have a "char *" as the input argument and a "char *" as the return argument.
If the function name is char *modify_input_str(char *) then add the following call in
cmeapi_init():
cmeapi_register_modify_input_str(modify_input_str);

The following functions are provided to enable you to "register" three types of functions:

void cmeapi_register_start_init(vvFunc fptr);


Use the function void cmeapi_register_start_init(vvFunc fptr) to register your own
function that is called at the start of initialization which has no input arguments and does
not return anything: void fptr(void);

void cmeapi_register_modify_input_str(ccFunc fptr);


Use the function void cmeapi_register_modify_input_str(ccFunc fptr) to register your
own function to modify the input string which has one one string input argument and
returns the modified string: char *fptr(char *);

void cmeapi_register_modify_output_str(ccFunc fptr);


Use the function void cmeapi_register_modify_output_str(ccFunc fptr) to register
your own function to modify the output string which has one string input argument and
returns the modified string: char *fptr(char *);

26
VERICUT Development Tools

VERICUT Machine Simulation CMEAPI C-functions


Reference

DllExport void cmeapi_init(void)

This function is called when the DLL is loaded. You must define this functions in your
DLL.

void cmeapi_register_macro(char *name, void *(func_ptr))

Use this function to define a macro in VERICUT. This function should be called in
cmeapi_init()

The following is an example of code to needed to define, initialize, and register Macros
in VERICUT.

#include "cmeapi_import.h"

/* ************************************************************************** */
void UserTest(char *, char *, value)

{
printf("My UserTest macro was called\n");
}

/* ************************************************************************** */
DllExport void cmeapi_init(void)

{
printf("My cmeapi_init() was called\n");
cmeapi_register_macro("UserTest", UserTest);
}

27
VERICUT Development Tools

The following functions were converted from the CGTech Macro Language:

void cmeapi_abort_processing();
Causes immediate, normal termination of machine code block processing.

void cmeapi_activate_head(tool_comp_name, spindle_comp_name,


css_flag);
char *tool_comp_name;
char *spindle_comp_name;
double css_flag
Causes the specified tool head to become active. For example: if there is 2 heads on the
machine (A and B). Activating "A", and then calling for a tool change would cause the
tool to be connected to head A.

void cmeapi_add_nurbs_ctrl(xval, yval, zval, ivector, jvector, kvector,


weight);
double xval;
double yval;
double zval;
double ivector;
double jvector;
double kvector;
double weight;
Add a control point to the NURBS structure.

See also:
void cmeapi_add_nurbs_knot(knot);
void cmeapi_add_nurbs_objdata(knot);
void cmeapi_convert_nurbs_2_apt(subsystem, xreg, yreg, zreg, sequence_no);
void cmeapi_free_nurbs();
void cmeapi_free_nurbs_objdata(knot);
void cmeapi_init_nurbs();
double cmeapi_nurbs_get_next_point(xval, yval, zval);
void cmeapi_set_nurbs_order(order);

28
VERICUT Development Tools

void cmeapi_add_nurbs_knot(knot);
double knot;

Add a knot point to the NURBS structure.

See also:
void cmeapi_add_nurbs_ctrl(xval, yval, zval, ivector, jvector, kvector, weight);
void cmeapi_add_nurbs_objdata(knot);
void cmeapi_convert_nurbs_2_apt(subsystem, xreg, yreg, zreg, sequence_no);
void cmeapi_free_nurbs();
void cmeapi_free_nurbs_objdata(knot);
void cmeapi_init_nurbs();
double cmeapi_nurbs_get_next_point(xval, yval, zval);
void cmeapi_set_nurbs_order(order);.

void cmeapi_add_nurbs_objdata(knot);
double knot;
This function saves the current input data and associates it with the specified knot point.
This is used by OptiPath.

See also:
void cmeapi_add_nurbs_ctrl(xval, yval, zval, ivector, jvector, kvector, weight);
void cmeapi_add_nurbs_knot(knot);
void cmeapi_convert_nurbs_2_apt(subsystem, xreg, yreg, zreg, sequence_no);
void cmeapi_free_nurbs();
void cmeapi_free_nurbs_objdata(knot);
void cmeapi_init_nurbs();
double cmeapi_nurbs_get_next_point(xval, yval, zval);
void cmeapi_set_nurbs_order(order);

void cmeapi_anystrmatch(textstr1,textstr2);
This routine is passed any 2 "text" objects and returns "1" if they match, and "0" if they
don't.
NOTE: The comparison that is made is case insensitive.

29
VERICUT Development Tools

double cmeapi_atan_depth(expression);
char *expression;
Returns the depth of the current expression after the ATAN. It is assumed that [ ] will be
used as left and right precedence operators. The expression "ATAN [[[a/b]" has a current
depth of 2. If ATAN is not present in the string, the depth will be set to 1.

double cmeapi_calculate_angular_rate(tolerance, angle, radius);


double tolerance;
double angle
double radius
Returns the percentage rate based on the number of chords to used to represent an arc.
The first argument is the rotary motion tolerance value. The second value is the angle of
the arc endpoints. The third argument is the radius of the arc. The return value is the
angular percentage rate.

double cmeapi_check_word_in_block(start, word, minval, maxval);


double start;
char *word;
double minval; /* Optional */
double maxval; /* Optional */

Returns the position number of the specified word in a block of machine code. It begins
searching at start position in the block, trying to match the next word with an address
greater than or equal to the minval and less than or equal to the maxval. Minval and
maxval are optional range values. If maxval is not supplied, it matches only the word. It
returns 0, if there is no word/address matched in the block.

An example using the block: N010G90G01X.1Y3

a = void cmeapi_check_word_in_block(1, "G");


b = void cmeapi_check_word_in_block(a+1, "G");
c = void cmeapi_check_word_in_block(1, "G", 0, 3);
d = void cmeapi_check_word_in_block(1, "G", 17, 19);
e = void cmeapi_check_word_in_block(1, "G", 1);
f = void cmeapi_check_word_in_block(1, "G", 2);

The value of "a" is 2, because G90 is first word "G". The value of "b" is 3, because start
is 3, searching begins at G01. The value of "c" is 3, because G01 matches the word "G"
and the address 01 is between 0 and 3. The value of "d" is 0, because there is no word
"G" with an address that is between 17 and 19. The value of "e" is 3, because G01

30
VERICUT Development Tools

matches the word "G" and the address 01 matches the minval 1. The value of "f" is 0,
because there is no word "G" with an address equal to 2.

See also:
double cmeapi_current_command_number();

CMEAPI_VECTOR cmeapi_circle_normal(motion_plane, x_comp_name,


y_comp_name, z_comp_name, subsystem);
double motion_plane;
char *x_comp_name;
char *y_comp_name;
char *z_comp_name;
char *subsystem;

Calculates the normal to the specified motion plane relative to the part.

void cmeapi_call_macro(macro_name, word, textstr, value);


char *macro_name;
char *word;
char *textstr;
double value;

This function calls a registered macro within the C source. The first argument specifies
the name of the macro to be called. The remaining arguments are the standard arguments
for a Word/Value macro.

char *cmeapi_cms_native(nt_string, ...);


Converts the specified string into a native text string. The first argument is the native text
string, and the remaining arguments are the arguments to the native text string. The
resultant string is returned.

double cmeapi_comp_tool_side(comp_name, subsystem);


char *comp_name;
char *subsystem;

Returns 1 if the specified component is on the tool side of the machine, and returns 0 if it
is not.

31
VERICUT Development Tools

void cmeapi_connect_component(comp_name_1, comp_name2);


char *comp_name_1
char *comp_name_2

Disconnects component 1 from it's parent component and connects it to component 2.

CMEAPI_VECTOR cmeapi_convert_machine_vector(input);
CMEAPI_VECTOR input;

Returns a vector converted from the input vector using the matrix calculated using the
components from the part to the base.

See also:
void cmeapi_set_fixture_offsets(subsystem, comp_reg_name, value);
void cmeapi_set_tool_length_offset(z_offset);

void cmeapi_convert_nurbs_2_apt(subsystem, xreg, yreg, zreg,


sequence_no);
char *subsystem;
char *xreg;
char *yreg;
char *zreg;
double sequence_no;

This function converts the previously defined NURBS curve into APT format, and prints
the result to the "OUTPUT" location. The input arguments are the register names for the
x, y, and z components, and the current sequence number.

See also:
void cmeapi_add_nurbs_ctrl(xval, yval, zval, ivector, jvector, kvector, weight);
void cmeapi_add_nurbs_knot(knot);
void cmeapi_add_nurbs_objdata(knot);
void cmeapi_free_nurbs();
void cmeapi_free_nurbs_objdata(knot);
void cmeapi_init_nurbs();
double cmeapi_nurbs_get_next_point(xval, yval, zval);
void cmeapi_set_nurbs_order(order);

32
VERICUT Development Tools

double cmeapi_current_command_number();
Returns the position number of the current object. For example a block of
N010G01X.1Y3, the N010 word/address is in the first object, the G01 word/address is
the second object, and so on.

See also:
double cmeapi_check_word_in_block(start, word, minval, maxval);

void cmeapi_default_word(word);
Defines a default word to be used if a number is read without a corresponding word
(during tokenizing).

void cmeapi_disable_all_macros();
Disables all macros from being called while tokenizing a block.

void cmeapi_edm_wire(show_wire_flag, wire_thickness)


double show_wire_flag;
double wire_thickness;

Sets 2 attributes associated with the wire. It is used while processing wire EDM jobs.
Show_wire_flag specifies whether the wire should be shown with the machine simulation
(1 for yes, and 0 for no), and the wire_thickness specifies the diameter of the wire.

NOTE: The wire_thickness is currently being ignored by Machine Simulation. The


wire will be drawn as a single pixel in width.

double cmeapi_format_number(format, type, value);


char *format;
double type;
char *string;
Returns a number using format and type to convert string.

33
VERICUT Development Tools

See also:
char *cmeapi_get_inch_format(word);
double cmeapi_get_inch_type(word);
char *cmeapi_get_metric_format(word);
double cmeapi_get_metric_type(word);
double cmeapi_get_multiplier(word);
void cmeapi_set_if_cond(flag);
void cmeapi_set_metric_mode();

void cmeapi_free_nurbs();
Frees the data associated with a NURBS structure. This routine should be called after the
processing of each NURBS statement.

See also:
void cmeapi_add_nurbs_ctrl(xval, yval, zval, ivector, jvector, kvector, weight);
void cmeapi_add_nurbs_knot(knot);
void cmeapi_add_nurbs_objdata(knot);
void cmeapi_convert_nurbs_2_apt(subsystem, xreg, yreg, zreg, sequence_no);
void cmeapi_free_nurbs_objdata(knot);
void cmeapi_init_nurbs();
double cmeapi_nurbs_get_next_point(xval, yval, zval);
void cmeapi_set_nurbs_order(order);

void cmeapi_free_nurbs_objdata(knot);
double knot;

This function frees the data that was previously allocated by void
cmeapi_add_nurbs_objdata().

See also:
void cmeapi_add_nurbs_ctrl(xval, yval, zval, ivector, jvector, kvector, weight);
void cmeapi_add_nurbs_knot(knot);
void cmeapi_add_nurbs_objdata(knot);
void cmeapi_convert_nurbs_2_apt(subsystem, xreg, yreg, zreg, sequence_no);
void cmeapi_free_nurbs();
void cmeapi_init_nurbs();
double cmeapi_nurbs_get_next_point(xval, yval, zval);
void cmeapi_set_nurbs_order(order);

34
VERICUT Development Tools

CMEAPI_VECTOR cmeapi_get_adj_tool_axis();
Returns the adjusted tool axis in its current position.

double cmeapi_get_alpha_nc_var(variable_name);
char *variable_name;

Returns the value for the nc variable, variable_name .

See also:
void cmeapi_get_nc_vars(nc_vars, start, end);
void cmeapi_set_alpha_nc_var(variable_name, value);
void cmeapi_set_nc_vars(nc_vars, start, end);

double cmeapi_get_apt_7(parm1, parm2, parm3, parm4, parm5, parm6,


parm7);
If the current tool is defined as a 7 parameter APT cutter, a value of 1 will be returned,
and the 7 parameters will be returned in the 7 arguments. Otherwise a value of 0 will be
returned.

double cmeapi_get_block_sequence();
Returns the current block sequence count (the total number of blocks that has been
processed.

void cmeapi_get_c_3d_offset_parms(offset, i_present, j_present,


k_present);
CMEAPI_VECTOR offset;
double i_present;
double j_present;
double k_present;

Returns the values associated with a 3 dimensional offset parameter structure.

35
VERICUT Development Tools

CMEAPI_POINT cmeapi_get_c_3d_vars(variable);
double variable;

Returns the CMEAPI_POINT value of a specific variable. Supported variables include:


CMS_C_PART_NORMAL:
CMS_C_TOOL_VECTOR:
CMS_C_OFFSET_3D:
CMS_C_TOOL_MOTION_VECTOR:
CMS_C_LEADRATE:
CMS_C_CDC_OFF_ADJ_PT:
CMS_C_HEAD_VECTOR:

double cmeapi_get_c_array_vars(variable, index);


double variable;
double index;

Returns the value of a specific variable. This function is used with array variables. The
indexed value into the specified array will be returned. Supported variables include:
CMS_C_BLOCK_NC_VACANT_VARS:
CMS_C_VAR_ARGUMENTS:
CMS_C_SEQ_LOOP_CNT:
CMS_C_SEQ_START:
CMS_C_ARGUMENTS:
CMS_C_SEQ_END:
CMS_C_SEQ_SUB:
CMS_C_SEQ_CALL:
CMS_C_BLOCK_NC_VARS:
CMS_C_MODAL_NC_VARS:
CMS_C_MODAL_NC_VACANT_VARS:
CMS_C_ROTATE_3D_MAT:

36
VERICUT Development Tools

CMEAPI_AXIS cmeapi_get_c_axis_vars(variable);
double variable;

Returns the CMEAPI_AXIS value of a specific variable. Supported variables include:


CMS_C_INPUT_AXIS:
CMS_C_BASE_WORK_OFFSET:
CMS_C_TOOL_NOSE_VALUE:
CMS_C_TOOL_RETRACT_FLAG:
CMS_C_INPUT_MACHINE_ZERO:
CMS_C_INPUT_PROGRAM_ZERO:
CMS_C_INITIAL_SPINDLE_LOC:
CMS_C_MACH_REF_POINT:
CMS_C_SAV_SHIFT_OFFSET:

void cmeapi_get_c_circle_parms(i, j, k, r, i_present, j_present, k_present,


r_present, pitch);
double i;
double j;
double k;
double r;
double i_present;
double j_present;
double k_present;
double r_present;
double pitch;

Returns the values associated with a circle parameter structure.

void cmeapi_get_c_fixture(index, offset);


double index;
CMEAPI_AXIS offset;

Returns the specified fixture offset.

37
VERICUT Development Tools

void cmeapi_get_c_mirror(xflag, yflag, zflag, aflag, bflag, cflag, xval, yval,


zval, aval, bval, cval);
double xflag;
double yflag;
double zflag;
double aflag;
double bflag;
double cflag;
double xval;
double yval;
double zval;
double aval;
double bval;
double cval;

Returns the values associated with a mirror structure.

double cmeapi_get_c_numeric_vars(variable);
double variable;

Returns the number value of a specific variable. Supported variables include:


CMS_C_LOOP_COUNT:
CMS_C_TCOUNT:
CMS_C_MOTION: TRUE/FALSE
CMS_CHANGE_CYCLE: TRUE/FALSE
CMS_C_SPINDLE_VALUE:
CMS_C_DWELL_TIME:
CMS_C_WHILE_COND: TRUE/FALSE
CMS_C_IF_COND: TRUE/FALSE
CMS_C_WORK_COORD_INDEX:
CMS_C_TURRET_INDEXING: TRUE/FALSE
CMS_C_CUTTER_COMP_MULTIPLIER:
CMS_C_ARGUMENT_INDEX:
CMS_C_VAR_ARGS_INDEX:
CMS_C_SUB_STARTING_SEQ:
CMS_C_TYPEII_ARG_COUNT:
CMS_C_OPTIMIZABLE_COUNT:
CMS_C_ABSINC: ABSOLUTE/INCREMENTAL
CMS_C_MOTION_TYPE:
MOTION_RAPID/MOTION_LINEAR/MOTION_CW/MOTION_CCW/MOTION_HE

38
VERICUT Development Tools

L_CW/MOTION_HEL_CCW/MOTION_FROM/MOTION_THREAD/MOTION_NUR
BS/MOTION_POLY
CMS_C_PREV_NON_RAPID_MOTION:
MOTION_RAPID/MOTION_LINEAR/MOTION_CW/MOTION_CCW/MOTION_HE
L_CW/MOTION_HEL_CCW/MOTION_FROM/MOTION_THREAD/MOTION_NUR
BS/MOTION_POLY
CMS_C_UNITS: CTL_INCH/CTL_METRIC
CMS_C_CUTCOM_MODE:
CUTCOM_OFF/CUTCOM_RAMPON/CUTCOM_RAMPOFF/CUTCOM_ON
CMS_C_MOTION_PLANE: XY_PLANE/ZX_PLANE/YZ_PLANE
CMS_C_CUTCOM_METHOD:
CMS_C_FEED_MODE:
FEED_PER_MINUTE/FEED_PER_REVOLUTION/INVERSE_TIME
CMS_C_CUTTER_COMP_VALUE:
CMS_C_CUTTER_COMP_INDEX:
CMS_C_CUTTER_OFFSET_VALUE:
CMS_C_TOOL_LEN_COMP
CMS_C_TOOL_LEN_COMP_DIR:
CMS_C_TOOLNUM:
CMS_C_SPINDLE_SPEED:
CMS_C_D3_TOOL_OFFSET_FLAG: TRUE/FALSE
CMS_C_FEEDRATE:
CMS_C_NEW_OVERRIDE_FEEDRATE: TRUE/FALSE
CMS_C_CUR_WORK_COORD:
CMS_C_SUB_CALL: TRUE/FALSE
CMS_C_SEQ_NEST_LEVEL:
CMS_C_ROTARY_ABS_DIRECTION:
ROTARY_POS_CCW/ROTARY_POS_CW/ROTARY_ALWAYS_CW/ROTARY_AL
WAYS_CW/ROTARY_SHORTEST_DISTANCE/ROTARY_LINEAR
CMS_C_ACTIVE_TOOL_NUMBER:
CMS_C_TOOL_OFFSET_NUM:
CMS_C_CDC_OFF_ADJ: TRUE/FALSE
CMS_C_LOWER_GUIDE_H:
CMS_C_UPPER_GUIDE_H:
CMS_C_LOWER2REF_PLANE:
CMS_C_REF2UPPER_PLANE:
CMS_C_SHOW_WIRE: TRUE/FALSE
CMS_C_CYCLE_SUBROUTINE: TRUE/FALSE
CMS_C_CYCLE_SUBROUTINE_DEPTH:
CMS_C_DYN_3D_TOOL_OFFSET:
CMS_C_MILLINTMODE_FLAG: TRUE/FALSE
CMS_C_NC_MACRO_MOTION: TRUE/FALSE
CMS_C_W_TOOL_SIDE: TRUE/FALSE
CMS_C_Z_TOOL_SIDE: TRUE/FALSE
CMS_C_W_ZERO_TRACKING: PRIMARY/SECONDARY
CMS_C_Z_ZERO_TRACKING: PRIMARY/SECONDARY

39
VERICUT Development Tools

CMS_C_TYPEII_STATE_INDEX:
CMS_C_PROBE_OFFSET_CNT:
CMS_C_PROBE_OFFSET_CNT:
CMS_C_RTCP: TRUE/FALSE
CMS_C_CYCLE_Z_AXIS: TRUE/FALSE
CMS_C_MULTI_AXIS_CYCLE: TRUE/FALSE
CMS_C_ROTATE_3D: TRUE/FALSE
CMS_C_APPLY_PIVOT_OFFSET: TRUE/FALSE
CMS_C_MULTIPLE_PASS: TRUE/FALSE
CMS_C_MULTIPASS_NEEDED: TRUE/FALSE
CMS_C_PASS_NUMBER:
CMS_C_MULTI_AXIS_MACHINE: TRUE/FALSE
CMS_C_MILLTURN: MILLING/TURNING/WIRE_EDM
CMS_C_MAX_TABLE_SPEED:
CMS_C_SURFACE_SPEED:
CMS_C_SPINDLE_MODE: SPINDLE_CSS/SPINDLE_RPM
CMS_C_PROGRAMMING_METHOD:
CMS_C_TURRET_TOOLS_LOADED:
CMS_C_EPSILON:
CMS_C_ANGLE_EPSILON:
CMS_C_TANGENT_EPSILON:
CMS_C_MAZAK_PART_LOADER_CNT:

void cmeapi_get_c_nurbs(opti_state, order, weight, knot, incre_knot,


ctl_cnt, knot_cnt, start_pos);
double opti_state;
double order;
double weight;
double knot;
double incre_knot;
double ctl_cnt;
double knot_cnt;
CMEAPI_AXIS start_pos;

Returns the values associated with the current NURBS structure.

40
VERICUT Development Tools

void cmeapi_get_c_poly(bx, ax, by, ay, bz, az, t);


double bx;
double ax;
double by;
double ay;
double bz;
double az;
double t;

Returns the values associated with a Siemens polynomial.

void cmeapi_get_c_precision(x_metric, x_inch, y_metric, y_inch, z_metric,


z_inch);
double x_metric;
double x_inch;
double y_metric;
double y_inch;
double z_metric;
double z_inch;

Returns the format values associated with the X, Y, and Z words.

void cmeapi_get_c_probe_offset(index, id, offset);


double index;
double, id;
double, offset[];

Returns the specified probe id and offset.

void cmeapi_get_c_program(old_axis, old_asign, old_bsign, old_csign,


old_count, old_map, old_active, new_axis, new_asign, new_bsign,
new_csign, new_count, new_map, new_active);
CMEAPI_AXIS old_axis;
double old_asign;
double old_bsign;
double old_csign;
CMEAPI_AXIS old_count;
CMEAPI_POINT old_map;
CMEAPI_AXIS new_active;

41
VERICUT Development Tools

CMEAPI_AXIS new_axis;
double new_asign;
double new_bsign;
double new_csign;
CMEAPI_AXIS new_count;
CMEAPI_POINT new_map;
CMEAPI_AXIS new_active;

Returns the values associated with a program structure.

void cmeapi_get_c_rotate(flag, angle, angles, matrix_flag, plane,


xyz_mode, axis_flags, position, specified_position, matrix);
double flag;
double angle;
double angles[];
double matrix_flag;
double plane;
double xyz_mode;
CMEAPI_AXIS axis_flags;
CMEAPI_AXIS position;
CMEAPI_POINT specified_position;
double matrix[];

Returns the values associated with a rotation structure.

char *cmeapi_get_c_text_vars(variable);
double variable:

Returns the text value of a specific variable. Supported variables include:


CMS_C_LABEL_NAME:
CMS_C_LAST_FEEDRATE_STATEMENT:
CMS_C_SUBROUTINE_NAME:
CMS_C_ACTIVE_TOOL_NAME:
CMS_C_ACTIVE_SPINDLE_NAME:
CMS_C_SPINDLE_DIR:
CMS_C_CYCLE_SUBROUTINE_NAME:

42
VERICUT Development Tools

void cmeapi_get_c_typeII_arg(index, textstr, value, argtype);


double index;
char *textstr;
double value;
double argtype;

Returns the values associated with the specified typeII argument (the input argument that
specifies which type II argument you want data on). If index is set to -1, the type II
special argument is returned.

For example: (ABC, 5, 10+5, test; 1)


Index 1:
char *= "5"
value = 5
argtype = 1 (numeric argument)

Index 2:
char *= "10+5"
value = 15
argtype = 1

Index 3:
char *= "test"
value = 0
argtype = 2 (text argument)

Index -1:
char *= "1"
value = 1
argtype = 1 (???)
The special argument is the argument that comes after the ";".

void cmeapi_get_c_typeII_state(index, textstr);


double index;
char *textstr;

Returns the specified type II state.

43
VERICUT Development Tools

void cmeapi_get_c_work_parms(values, present_flags);


CMEAPI_AXIS values;
CMEAPI_AXIS present_flags

Returns the values associated with a work parameter structure.

CMEAPI_POINT cmeapi_get_component_location(comp_register_name);
char *comp_register_name

Returns the location of the origin point of the specified component.

double cmeapi_get_file_id();

Returns the id associated with the current input file.

void cmeapi_get_filenames(ctl_filename, job_filename, cme_filename,


input_filename, output_filename, log_filename, machine_filename,
tls_filename, full_path_flag);
char *ctl_filename;
char *job_filename;
char *cme_filename;
char *input_filename;
char *output_filename;
char *log_filename;
char *machine_filename;
char *tls_filename;
double full_path_flag;

Returns the various filenames that are being used by this job in the corresponding
arguments. The full_path_flag is set to 1, the full path name will be returned for each file,
otherwise only the last level file name will be returned.

double cmeapi_get_gage_length(tool_component);
char *tool_component;

Returns the length of the tool which is connected to the specified component as measured
from the zero point of the tool to the gage_line. If a tool component is not specified, the
current active tool component will be used.

44
VERICUT Development Tools

double cmeapi_get_gage_offset(active_tool_component);
char *active_tool_component;

Calculates and returns the gage offset for the current tool in the "active_tool_component".
This is calculated as: GAGEPOINT_OFFSET - DRIVENPOINT_OFFSET. This function
replaces void cmeapi_get_gage_length() which only retrieved the Z Axis length of the
tool.

double cmeapi_get_gage_offset2(active_tool_component);
char *active_tool_component;

Calculates and returns the gage offset for the current tool in the "active_tool_component".
This is calculated as: -(Cutter Origin Offset + DRIVENPOINT_OFFSET). This function
is only used in special circumstances. Typically, the void cmeapi_get_gage_offset()
macro is used instead of this function.

double cmeapi_get_guide_z_distance();
Returns the vertical distance between the guides.

char *cmeapi_get_inch_format(word);
char *word;

Returns the inch format string for the specified word .

See also:
double cmeapi_format_number(format, type, value);
double cmeapi_get_inch_type(word);
char *cmeapi_get_metric_format(word);
double cmeapi_get_metric_type(word);
double cmeapi_get_multiplier(word);
void cmeapi_set_if_cond(flag);
void cmeapi_set_metric_mode();

45
VERICUT Development Tools

double cmeapi_get_inch_type(word);
char *word;

Returns the inch type for the specified word . A return value of 0 means Decimal, 1
means Leading, and 2 means Trailing.

See also:
double cmeapi_format_number(format, type, value);
char *cmeapi_get_inch_format(word);
char *cmeapi_get_metric_format(word);
double cmeapi_get_metric_type(word);
double cmeapi_get_multiplier(word);
void cmeapi_set_if_cond(flag);
void cmeapi_set_metric_mode();

void cmeapi_get_input_block();
Returns the current block.

double cmeapi_get_input_location();
Returns the position in the machine code file of the current block.

See also:
double cmeapi_get_next_input_location();
double cmeapi_set_input_location(location, sequence_number, file_id);

void cmeapi_get_last_token(word, value);


char *word;
double value;

Returns the last word/value that was processed.

char *cmeapi_get_macro_modal(modal_name);
char *modal_name;

Returns the value of the specified macro modal, modal_name .

46
VERICUT Development Tools

See also:
void cmeapi_get_last_token(word, value);

char *cmeapi_get_metric_format(word);
char *word;

Returns the metric format string for the specified word .

See also:
double cmeapi_format_number(format, type, value);
char *cmeapi_get_inch_format(word);
double cmeapi_get_inch_type(word);
double cmeapi_get_metric_type(word);
double cmeapi_get_multiplier(word);
void cmeapi_set_if_cond(flag);
void cmeapi_set_metric_mode();

double cmeapi_get_metric_type(word);
char *word;

Returns the metric type for the specified word . A return value of 0 means Decimal, 1
means Leading, and 2 means Trailing.

See also:
double cmeapi_format_number(format, type, value);
char *cmeapi_get_inch_format(word);
double cmeapi_get_inch_type(word);
char *cmeapi_get_metric_format(word);
double cmeapi_get_multiplier(word);
void cmeapi_set_if_cond(flag);
void cmeapi_set_metric_mode();

char *cmeapi_get_mm_menu_string(modal_item);
char *modal_item;

Returns the text string that is to be associated with the specified macro modal menu item.

47
VERICUT Development Tools

void cmeapi_get_mm_widget_string(label_widget, value_widget,


label_string, value_string);
char *label_widget;
char *value_widget;
char *label_string;
char *value_string;

Returns the text string that is to be associated with the specified widget and its value. The
first argument is the name of the label widget. The second argument is the name of the
value widget (if it is a choice item). The corresponding label string and value string are
returned in the third and fourth arguments.

double cmeapi_get_multiplier(word);
char *word;

Returns the multiplier for the specified word.

See also:
double cmeapi_format_number(format, type, value);
char *cmeapi_get_inch_format(word);
double cmeapi_get_inch_type(word);
char *cmeapi_get_metric_format(word);
double cmeapi_get_metric_type(word);
void cmeapi_set_if_cond(flag);
void cmeapi_set_metric_mode();
void cmeapi_get_input_block();
double cmeapi_set_input_location(location, sequence_number, file_id);

int cmeapi_get_nc_vacant_var(var_name);
double var_name;

Returns a value (1 for YES or 0 for NO) indicating whether the specified nc variable has
been set.

48
VERICUT Development Tools

void cmeapi_get_nc_vacant_vars_list(int_array, start_index, end_index);


int *int_array;
int start_index;
int end_index;

Returns in the first argument, an array of numbers (1 for YES or 0 for NO) indicating
whether the specified nc variables have been set. The vacant indicator array of numbers
corresponds to the nc variables starting with the second argument (start_index) and
ending with the third argument (end_index).

double cmeapi_get_nc_var(var_name);
double var_name;

Returns the value for the nc variable specified by the var_name.

void cmeapi_get_nc_vars_list(dbl_array, start_index, end_index);


double *dbl_array;
int start_index;
int end_index;

Returns an array of values for the nc variables beginning from start index and ending at
end index.

See also:
double cmeapi_get_alpha_nc_var(variable_name);
void cmeapi_set_alpha_nc_var(variable_name, value);
void cmeapi_set_nc_vars(nc_vars, start, end);

double cmeapi_get_next_input_location();
Returns the machine code file position of the beginning of the next block following the
current block.

double cmeapi_get_num_errors();
Returns the number of errors which have occurred.

49
VERICUT Development Tools

double cmeapi_get_num_warns();
Returns the number of warnings which have occurred.

double cmeapi_get_number_of_objects();
Returns the number of objects in the current block.

double cmeapi_get_number_of_opti_objects();
Returns the number of optimizeable objects in the current block. Comments and
assignments are not included in this list of objects.

char *cmeapi_get_operator_input();
Raises the main message window, and prompts the operator for input. The operator's
input is then returned.

void cmeapi_get_opti_block_type(return_value);
double return_value;

Returns the current opti_block_type as specified within Vericut. Possible values are:
VC_UNDEFINED, VC_FIRST_BLOCK, VC_MIDDLE_BLOCK, and
VC_LAST_BLOCK. This is used to detemine which word/value pairs will be in the
current output block.

char *cmeapi_get_part_spindle();
Returns the name of the first ROTARY or SPINDLE component that is found moving
from the part to the base. If no ROTARY or SPINDLE component is found, an empty
string is returned.

CMEAPI_OFFSET_TYPE void cmeapi_get_pivot_offset();


Returns the position of the tool's zero point relative to its rotary component axis. This is
the pivot point when running in "Rotary Tool Control Point" (RTCP) mode.

50
VERICUT Development Tools

double cmeapi_get_programming_method();
Returns the programming method (0 for tool tip, 1 for gage length, and 2 for tool length
compensation).

void cmeapi_get_rapid_traversal(comp_register_name, subsystem,


pos_priority, neg_priority, rapid_feedrate, pos_interpolated,
neg_interpolated);
char *comp_register_name;
char *subsystem;
double pos_priority;
double neg_priority;
double rapid_feedrate;
double pos_interpolated;
double neg_interpolated;

Returns a series of information associated with RAPID motion for the specified
component.

void cmeapi_get_stats(error_cnt, warnings_cnt, time, linear_time, distance,


linear_distance);
double error_cnt;
double warnings_cnt;
double time;
double linear_time;
double distance;
double linear_distance;

Returns the above statistics.

double cmeapi_get_table_value(table_name, subsystem, table_index,


value);
char *table_name;
char *subsystem;
double table_index;
double value;

Sets value to the element indexed by table_index in the table table_name .

51
VERICUT Development Tools

CMEAPI_VECTOR *cmeapi_get_tool_axis();

Returns the tool's orientation I,J,K, vector in the structure CMEAPI_VECTOR.

CMEAPI_POINT
cmeapi_get_tool_axis_position(tool_name);
char *tool_name;

Returns the tool's position X,Y,Z in the structure CMEAPI_POINT.

OFFSET_TYPE cmeapi_get_tool_comp_offset(x_offset, y_offset, z_offset,


x_reg, y_reg, z_reg);
double x_offset;
double y_offset;
double z_offset;
char *x_reg;
char *y_reg;
char *z_reg;

This function is passed a X,Y,Z offset that is to be applied to the current tool component.
This functions multiplies this offset by the tool's current transformation matrix, and
returns this value within the structure OFFSET_TYPE. It also returns within the 4th, 5th,
and 6th arguments, the register names of the components which moves the current tool
component along the X,Y,Z axis. Here is the definition of the OFFSET_TYPE type
structure.

type OFFSET_TYPE {
double x, y, z, a, b, c, u, v, w;
};

CMEAPI_TOOL_REC cmeapi_get_tool_location(status_flag);
double status_flag;

Returns the current tool location's X, Y, Z position as well as the tool orientation I, J, K,
vector in the structure CMEAPI_TOOL_REC. Here is the definition of the
CMEAPI_TOOL_REC type structure. If status flag is set to 1, the tool's position will be
updated within the status window.

52
VERICUT Development Tools

type CMEAPI_POINT {
double x,y,z;
};

type CMEAPI_VECTOR {
double i,j,k;
};

type CMEAPI_TOOL_REC {
CMEAPI_POINT pos;
CMEAPI_VECTOR vec;
};

See also:
double cmeapi_is_component_register(register_name);
double cmeapi_machine_is_multi_axis();
void cmeapi_process_motion(subsystem, register_name, value);

CMEAPI_TOOL_REC cmeapi_get_wire_location();
Returns the current position and angle of the wire. The current position is based off of the
lower guide.

double cmeapi_get_word_value(word, numeric_value, text_value);


char *word;
double numeric_value;
char *text_value;

If the specified word is found in the current block, the corresponding value will be
returned. If the value is a numeric value, the value will be returned in the second
argument and the function will return a 1. If the value is a text value, the value will be
returned in the third argument, and the function will return a 2. If the word is not found,
the function will return a 0.

void cmeapi_guides_fixed(lower_guide, upper_guide);


double lower_guide;
double upper_guide;

Determines whether either of the guides are fixed (in X and Y). The corresponding guide
is set to 0 if not fixed, and 1 if fixed.

53
VERICUT Development Tools

void cmeapi_init_nurbs();
Initializes a NURBS structure. This routine should be called at the beginning of each
NURBS statement.

See also:
void cmeapi_add_nurbs_ctrl(xval, yval, zval, ivector, jvector, kvector, weight);
void cmeapi_add_nurbs_knot(knot);
void cmeapi_add_nurbs_objdata(knot);
void cmeapi_convert_nurbs_2_apt(subsystem, xreg, yreg, zreg, sequence_no);
void cmeapi_free_nurbs();
void cmeapi_free_nurbs_objdata(knot);
double cmeapi_nurbs_get_next_point(xval, yval, zval);
void cmeapi_set_nurbs_order(order);

void cmeapi_init_polynomial(p1x, p1y, p1z, p2x, p2y, p2z, ax, bx, ay, by, az,
bz, t);
double p1x;
double p1y;
double p1z;
double p2x;
double p2y;
double p2z;
double ax;
double bx;
double ay;
double by;
double az;
double bz;
double t;

Inititializes of polynomial curve with its appropriate values. This routine was written
specifically for Siemens.

54
VERICUT Development Tools

void cmeapi_init_var(variable, data_type, text_value, numeric_value);


char *variable;
double data_type;
char *text_value
double numeric_value;

This function is the same as void cmeapi_set_var() except only initializes the variable if it
has not been initialized by the user (Job file). Sets the nc variable specified by the first
argument to either the double value of the fourth argument or the text value of the third
argument. The second argument contains the data type (1 for number, 2 for text).

double cmeapi_is_component_register(register_name);
char *register_name;

Returns the value 1 if register_name matches a component in the current machine.

See also:
MEAPI_TOOL_REC void cmeapi_get_tool_location(status_flag);
double cmeapi_machine_is_multi_axis();
void cmeapi_process_motion(subsystem, register_name, value);

double cmeapi_is_multiple_pass();
Returns 1 during multiple pass operation, otherwise a 0 is returned.

See also:
OFFSET_TYPE cmeapi_get_pivot_offset();

double cmeapi_is_optimizing();
Returns 1 if optipath is currently turned on, otherwise a 0 is returned.

void cmeapi_log(message);
char *message;

Outputs the specified message to the log file. If the log file is not defined, the message
will be printed to standard out.

55
VERICUT Development Tools

double cmeapi_machine_is_multi_axis();
Returns a 1 if the machine definition contains any rotary components or if the machine
tool normal vector is not (0, 0, 1).

See also:
CMEAPI_TOOL_REC cmeapi_get_tool_location(status_flag);
double cmeapi_is_component_register(register_name);
void cmeapi_process_motion(subsystem, register_name, value);

void cmeapi_max_errors(max_errors);
double max_errors;

Specifies the number of errors to allow before processing is stopped.

void cmeapi_max_warnings(max_warnings);
double max_warnings;

Specifies the number of warnings to allow before processing is stopped.

void cmeapi_mts_inc_time(delta_time, dwell_time, feed_mode,


spindle_speed, spindle_mode, max_table_speed);
double delta_time;
double dwell_time;
double feed_mode;
double spindle_speed;
double spindle_mode;
double max_table_speed;

This function is called to execute a dwell. In most cases, this will simply cause the time
to be incremented by delta_time . If, however, the current machine is a dual head
machine running in synchronous mode, additional calculations are done to keep the heads
in sync. This is the reason for the additional arguments. Delta_time is given in minutes.
Dwell_time is the specified dwell time. The units for the dwell_time is dependent on the
feed_mode . The feed_mode is 1 for "Feed Per Minute", 2 for "Feed Per Revolution", and
3 for "Inverse Time". The spindle_speed is specified as either "Revolutions Per Minute"
or "Units Per Minute" depending on the spindle_mode . The spindle_mode is 1 for
Constant Surface Speed, and 2 for RPM. Max_table_speed is specified in "Units Per

56
VERICUT Development Tools

Minute" and is used to calculate RPM when the spindle is in Constant Surface Speed
mode.

double cmeapi_nurbs_get_next_point(xval, yval, zval);


double xval;
double yval;
double zval;

This function returns the next point associated with the NURBS curve. This function
should not be called until the NURBS curve has been fully defined. The next point is
based off of the NURBS curve, and an internal tolerance value that is associated with the
NURBS curve. Returns 1 if there is a next point, otherwise it returns 0.

See also:
void cmeapi_add_nurbs_ctrl(xval, yval, zval, ivector, jvector, kvector, weight);
void cmeapi_add_nurbs_knot(knot);
void cmeapi_add_nurbs_objdata(knot);
void cmeapi_convert_nurbs_2_apt(subsystem, xreg, yreg, zreg, sequence_no);
void cmeapi_free_nurbs();
void cmeapi_free_nurbs_objdata(knot);
void cmeapi_init_nurbs();
void cmeapi_set_nurbs_order(order);

void cmeapi_operator_input(msg);
char *msg;

Sends a message to the operator and waits for input from the operator. The way this has
been implemented is that the specified msg is sent to the INFO location, and the
processing of the mcd file is stopped. The user/operator can then decide what to do next
in response to the specified msg .

void cmeapi_output(msg);
char *string;

The function void cmeapi_output() outputs string to the current output file. It outputs
string to standard output, when the output file is not specified.

57
VERICUT Development Tools

void cmeapi_output_text(msg, cutcom_mode);


char *string;
double cutcom_mode

This routine outputs a text string to action queue. When running in look ahead mode, text
output generally should not be sent out immediately, but buffered and sent out as the
block is processed. This routine insures that the text is sent out at the right time.

void cmeapi_pass1_tool_change(tool_num);
double tool_num;

This function is called during the scan pass and is used to build a tool list. This functions
allows a tool list to be created without fully processing the file. This function will only
work however if the file does not contain subroutines..

double cmeapi_poly_get_next_point(xval, yval, zval);


double xval;
double yval;
double zval;

This function returns the next point associated with the polynomial curve. This function
should not be called until the polynomial curve has been fully defined. The next point is
based off of the polynomial curve, and an internal tolerance value that is associated with
the polynomial curve. Returns 1 if these is a next point, otherwise it returns 0.

void cmeapi_process_cycle_motion(feed_to, rapid_to, retract_to,


step_down, step_up, initial_level, change_cycle_flag, x_comp_reg,
y_comp_reg, z_comp_reg, dwell_time, feedrate, feedmode, spindle_mode,
spindle_speed, max_table_speed, subsystem);
double feed_to; /* distance to feed from goto */
double rapid_to; /* distance to rapid to from goto */
double retract_to; /* final feed above toto */
double step_down; /* step down, 0 if not applicable */
double step_up; /* step up, 0 if not applicable) */
double initial_x_level; /* initial x level */
double initial_y_level; /* initial y level */
double initial_z_level; /* initial z level */
char *x_comp_reg; /* x register name */
char *y_comp_reg; /* y register name; */

58
VERICUT Development Tools

char *z_comp_reg; /* z register name */


double dwell_time;
double feedrate;
double feedmode;
double spindle_mode;
double spindle_speed;
double max_table_speed;
double delta_time;
double rapid_feedrate;
double intermediate_flag;
double rpoint_motion;
char *subsystem;

Executes the motion associated with a cycle statement.

void cmeapi_process_motion(subsystem, register_name, value);


char *subsystem;
char *register_name;
double value;

Rebuilds the register_name component's current matrix.

See also:
CMEAPI_TOOL_REC cmeapi_get_tool_location(status_flag);
double cmeapi_is_component_register(register_name);
double cmeapi_machine_is_multi_axis();

void cmeapi_process_mts_arc(x_center, y_center, z_center, arc_dir, plane,


x_start, y_start, z_start, x_end, y_end, z_end, radius, tolerance,
x_comp_reg, y_comp_reg, z_comp_reg, feedrate, feedmode,
spindle_mode, spindle_speed, max_table_speed, inverse_time,
active_spindle, normal_x, normal_y, normal_z, subsystem);
double x_center; /* center of arc */
double y_center; /* center of arc */
double z_center; /* center of arc */
double arc_dir; /* direction of arc: 1 = CCW, -1 =CW */
double plane; /* plane of the arc: 1 = XY, 2 = ZX, 3 = YZ */
double x_start; /* start point of arc */
double y_start; /* start point of arc */
double z_start; /* start point of arc */
double x_end; /* end point of arc */
double y_end; /* end point of arc */

59
VERICUT Development Tools

double z_end; /* end point of arc */


double radius;
double tolerance;
char *x_comp_reg;
char *y_comp_reg;
char *z_comp_reg;
double feedrate;
double feedmode;
double spindle_mode;
double spindle_speed;
double max_table_speed
double max_cutrate;
double invert_time;
char *active_spindle;
double normal_x;
double normal_y;
double normal_z;
char *subsystem;

Executes the motion of an arc.

void cmeapi_process_mts_motion(delta_time, velocity, feedmode,


spindle_mode, motion_mode, feedrate, spindle_speed, max_table_speed);
double delta_time;
double velocity;
double feedmode;
double spindle_mode;
double motion_mode;
double feedrate;
double spindle_speed;
double max_table_speed;

Executes normal (non-arc, noncycle) motion.

void cmeapi_process_sync();
char *register_name;
double value;

Tells the current head to stop processing and wait until the other head gets to the
corresponding sync location.

60
VERICUT Development Tools

void cmeapi_register_macro_modals(category, modals);


char *category;
char *modals;

Passes the macro modal information for a specific category to Machine Simulation. After
the CME file is loaded, Machine Simulation will call register_macro_modals(). This
macro then calls void cmeapi_register_macro_modals() repeatedly, once for each
category of macro modals. For each category , a menu item will be created in Machine
Simulation. The modals parameter contains a list of modal definitions, terminated with a
NULL string. Each modal definition contains a list of arguments, terminated with a
NULL string. The first argument is the label for the modal. The second argument is the
default value. If the modal is a text field, no other arguments are needed. If the modal is a
choice field, additional arguments are given for each choice field.

void cmeapi_register_states(state_variable, state_options);


char *state_variable;
char *state_options[];

Defines a CME state variable, and list the corresponding values that can be associated
with the given state variable.

void cmeapi_register_table_names(table_names);
char *table_names[];

Passes the list of table names that are defined in the CME. This list is used to create
dynamic menu options.

void cmeapi_reset_job_send_types();
Resets the information associated with the send_types. Calling void
cmeapi_set_send_value() dynamically allocate memory. This memory is freed with the
call to this function.

void cmeapi_reset_job_values();
Resets a few job values that are used by both Machine Simulation and the CME.
Currently these values include: num_errors, total_num_errors, num_warnings, and
total_time.

61
VERICUT Development Tools

void cmeapi_reset_states();
Resets the machsim state variables associated with the current CME.

void cmeapi_screen(message,);
char *message;

Prints the specified message to the screen. In general, this routine should not be used.
void cmeapi_send() is the preferred method of sending information.

void cmeapi_send(message_type, message, sequence_number);


double message_type;
char *message;
double sequence_number;

This is the general purpose function for the printing of all messages. Message_type
specifies the type of message (error, warning, info, debug,...). The message_type also
indicated the destination for the message. This relationship was established with the void
cmeapi_set_send_value() cfunc. For OUTPUT message types (6), the sequence_number
is concatenated to the message.

void cmeapi_set_active_tool(component_name);
char *component_name;

Sets the specified component_name as the active tool component.

void cmeapi_set_alpha_nc_var(variable_name, value);


char *variable_name;
double value;

Sets the nc variable, variable_name , to value .

See also:
double cmeapi_get_alpha_nc_var(variable_name);
void cmeapi_get_nc_vars(nc_vars, start, end);
void cmeapi_set_nc_vars(nc_vars, start, end);

62
VERICUT Development Tools

void cmeapi_set_c_3d_offset_parms(offset, i_present, j_present,


k_present);
CMEAPI_VECTOR offset;
double i_present;
double j_present;
double k_present;

Sets the values associated with a 3 dimensional offset parameter structure.

void cmeapi_set_c_3d_vars(variable point);


double variable;
CMEAPI_POINT point;

Sets the CMEAPI_POINT value of a specific variable. See void cmeapi_get_c_3d_vars()


for a list of supported variables.

void cmeapi_set_c_array_vars(variable, index);


double variable;
double index;
double value;

Sets the value of a specific variable. This function is used with array variables. The
indexed value into the specified array will be set. See double cmeapi_get_c_array_vars()
for a list of supported variables.:

void cmeapi_set_c_axis_vars(variable, axis_values);


double variable;
CMEAPI_AXIS, axis_values;

Sets the CMEAPI_AXIS value of a specific variable. See void cmeapi_get_c_axis_vars()


for a list of supported variables.

63
VERICUT Development Tools

void cmeapi_set_c_circle_parms(i, j, k, r, i_present, j_present, k_present,


r_present,pitch);
double i;
double j;
double k;
double r;
double i_present;
double j_present;
double k_prsent;
double r_present;
double pitch;

Sets the values associated with a circle parameter structure.

void cmeapi_set_c_fixture(index, offset);


double index;
CMEAPI_AXIS offset;

Sets the specified fixture offset.

void cmeapi_set_c_mirror(xflag, yflag, zflag, aflag, bflag, cflag, xval, yval,


zval, aval, bval, cval);
double xflag;
double yflag;
double zflag;
double aflag;
double bflag;
double cflag;
double xval;
double yval;
double zval;
double aval;
double bval;
double cval;

Sets the values associated with a mirror structure.

64
VERICUT Development Tools

void cmeapi_set_c_numeric_vars(variable, value);


double variable;
double value;

Sets the number value of a specific variable. See void cmeapi_get_c_numeric_values()


for a list of supported variables.

void cmeapi_set_c_nurbs(opti_state, order, weight, knot, incre_knot,


ctl_cnt, knot_cnt, start_pos);
double opti_state;
double order;
double weight;
double knot;
double incre_knot;
double ctl_cnt;
double knot_cnt;
CMEAPI_AXIS start_pos;

Sets the values associated with the current NURBS structure.

void cmeapi_set_c_poly(bx, ax, by, ay, bz, az, t);


double bx;
double ax;
double by;
double ay;
double bz;
double az;
double t;

Sets the values associated with a Siemens polynomial.

void cmeapi_set_c_precision(x_metric, x_inch, y_metric, y_inch, z_metric,


z_inch);
double x_metric;
double x_inch;
double y_metric;
double y_inch;
double z_metric;
double z_inch;

Sets the format values associated with the X, Y, and Z words.

65
VERICUT Development Tools

void cmeapi_set_c_probe_offset(index, id, offset);


double index;
double, id;
double, offset[];

Sets the specified probe id and offset.

void cmeapi_set_c_program(old_axis, old_asign, old_bsign, old_csign,


old_count, old_map, old_active, new_axis, new_asign, new_bsign,
new_csign, new_count, new_map, new_active);
CMEAPI_AXIS old_axis;
double old_asign;
double old_bsign;
double old_csign;
CMEAPI_AXIS old_count;
CMEAPI_POINT old_map;
CMEAPI_AXIS new_active;
CMEAPI_AXIS new_axis;
double new_asign;
double new_bsign;
double new_csign;
CMEAPI_AXIS new_count;
CMEAPI_POINT new_map;
CMEAPI_AXIS new_active;

Sets the values associated with a program structure.

void cmeapi_set_c_rotate(flag, angle, angles, matrix_flag, plane, xyz_mode,


axis_flags, position, specified_position, matrix);
double flag;
double angle;
double angles[];
double matrix_flag;
double plane;
double xyz_mode;
CMEAPI_AXIS axis_flags;
CMEAPI_AXIS position;
CMEAPI_POINT specified_position;
double matrix[];

Sets the values associated with a rotation structure.

66
VERICUT Development Tools

void cmeapi_set_c_text_vars(variable, textstr);


double variable:
char *textstr

Sets the text value of a specific variable. See char* cmeapi_get_c_text_vars() for a list of
supported variables.

void cmeapi_set_c_typeII_arg(index, textstr, argtype, value);


double index;
char *textstr;
double argtype;
double value;

Sets the values associated with the specified typeII argument. If index is set to -1, the
type II special argument is returned.

void cmeapi_set_c_typeII_state(index, textstr);


double index;
char *textstr;

Sets the specified type II state.

void cmeapi_set_c_work_parms(values, present_flags);


CMEAPI_AXIS values;
CMEAPI_AXIS present_flags

Sets the values associated with a work parameter structure.

void cmeapi_set_cml_block_skip(block_skip_char, num_switches,


switch_values);
char *block_skip_char;
double num_switches;
double switch_values; /* actually an array of numbers */

Passes the block skip information to Machine Simulation. Block_skip_char is the block
skip character marker. Num_switches indicates the number of switches that are

67
VERICUT Development Tools

supported, and switch_values are the current value for each switch (0 for OFF, and 1 for
ON).

void cmeapi_set_coolant(coolant_str);
char *coolant_str;

Passes the current coolant string to Machine Simulation. For example: COOLANT/ON or
COOLANT/MIST,... This is typically used to set the corresponding status field.

void cmeapi_set_ctl_state(state_variable, state_value);


char *state_variable;
char *state_value;

Sets the state of the specified state variable.

void cmeapi_set_cycle_component(component_register_name);
char *component_register_name;

Sets the component that is to be associated with a cycle.

void cmeapi_set_cycle_motion(cycle_motion_type);
double cycle_motion_type;

Set the type of cycle motion. Valid types are: IGNORE, BOTTOM_ONLY, or
FULL_MOTION.

void cmeapi_set_feedrate(feedrate, units_str);


double feedrate
char *units_str;

Passes the current feedrate to Machine Simulation. This is typically used to set the
corresponding status field.

68
VERICUT Development Tools

void cmeapi_set_fixture_offsets(subsystem, comp_reg_name, value);


char *subsystem;
char *comp_reg_name;
double value;

Sets the specified component's offset to the specified value.

NOTE: The component is specified by it's register name.

See also:
CMEAPI_VECTOR cmeapi_convert_machine_vector(input);
void cmeapi_set_tool_length_offset(z_offset);

void cmeapi_set_if_cond(flag);
double flag

Sets a flag indicating whether the previous "IF" condition was true or not.

void cmeapi_set_inch_mode();
Sets Machine Simulation into inch mode. In inch mode, Machine Simulation uses the
inch formats to convert all word values.

See also:
double cmeapi_format_number(format, type, value);
char *cmeapi_get_inch_format(word);
double cmeapi_get_inch_type(word);
char *cmeapi_get_metric_format(word);
double cmeapi_get_metric_type(word);
double cmeapi_get_multiplier(word);
void cmeapi_set_metric_mode();

69
VERICUT Development Tools

double cmeapi_set_input_location(location, sequence_number, file_id);


double location;
double sequence_number;
double file_id;

Sets the file position of the machine code file to location and the block sequence number
to sequence_number . The return value of 0 means the cfunc succeeded, a nonzero value
means failure. If file_id is present, it specifies the file being referenced.

See also:
double cmeapi_get_next_input_location();

void cmeapi_set_macro_modal(modal_name, string);


char *modal_name;
char *string;

Sets the specified macro modal, modal_name , to the value of string .

void cmeapi_set_math_precedence(value);
double value;

Sets the type of math precedence to be used when parsing the mcd file. Options are: 0 for
normal rules of mathematical precedence, and 1 for left to right precedence.

void cmeapi_set_metric_mode();
Sets Machine Simulation into metric mode. In metric mode, Machine Simulation uses the
metric formats to convert all word values.

See also:
double cmeapi_format_number(format, type, value);
char *cmeapi_get_inch_format(word);
double cmeapi_get_inch_type(word);
char *cmeapi_get_metric_format(word);
double cmeapi_get_metric_type(word);
double cmeapi_get_multiplier(word);
void cmeapi_set_if_cond(flag);

70
VERICUT Development Tools

void cmeapi_set_nc_vacant_vars(nc_vars, start, end);


double nc_vars[];
double start;
double end;

Sets the vacant flags for the nc variables beginning from start and ending at end to the
values beginning at the first position of nc_vars.

void cmeapi_set_nc_vars(nc_vars, start, end);


double nc_vars[];
double start;
double end;

Sets the values for the nc variables beginning from start and ending at end to the values
beginning at the first position of nc_vars.

See also:
double cmeapi_get_alpha_nc_var(variable_name);
void cmeapi_get_nc_vars(nc_vars, start, end);
void cmeapi_set_alpha_nc_var(variable_name, value);

void cmeapi_set_nurbs_order(order);
double order;

Sets the order of a NURBS statement.

See also:
void cmeapi_add_nurbs_ctrl(xval, yval, zval, ivector, jvector, kvector, weight);
void cmeapi_add_nurbs_knot(knot);
void cmeapi_add_nurbs_objdata(knot);
void cmeapi_convert_nurbs_2_apt(subsystem, xreg, yreg, zreg, sequence_no);
void cmeapi_free_nurbs();
void cmeapi_free_nurbs_objdata(knot);
void cmeapi_init_nurbs();
double cmeapi_nurbs_get_next_point(xval, yval, zval);

71
VERICUT Development Tools

void cmeapi_set_part_component_offset(xvalue, yvalue, zvalue);


double xvalue;
double yvalue;
double zvalue;

Sets the part component's X, Y, & Z offset values.

void cmeapi_set_program_block_start(value);
double value;

Sets the starting block, during the conversion pass, to be either the current block, or the
next block. If value is set to 0,set it to the current block. If value is set to 1, set it to the
next block. This function will typically only be called during the scan pass.

void cmeapi_set_send_value(msg_type, destination);


double msg_type;
double destination;

Specifies where to send a specific message type. Any number of message types can be
used. The following, however, have pre-defined meaning.
1 = Error
2 = Warning
3 = Informational
4 = Debug
5 = Input
6 = Output
10 = A continuation of a previous Error message

The possible destinations are defined with the following:


1 = log file
2 = output file
3 = screen

The above values can be added together. For example: A value of 5 specifies that the
destination is both the output file and the screen.

72
VERICUT Development Tools

void cmeapi_set_spindle(spindle_str);
char *spindle_str;

Passes the current spindle setting (ON, OFF, or speed) to Machine Simulation. This is
typically used to set the corresponding status field.

void cmeapi_set_spindle_mode(mode);
char *mode;

Passes the current spindle mode(1 for CSS, 2 for RPM) to Machine Simulation. This is
typically used to set the corresponding status field.

void cmeapi_set_tool_length_offset(z_offset);
double z_offset;

Sets the tool component's Z offset to the value of z_offset .

See also:
CMEAPI_VECTOR cmeapi_convert_machine_vector(input);
void cmeapi_set_fixture_offsets(subsystem, comp_reg_name, value);

void cmeapi_set_tool_offset(x_offset, y_offset,z_offset);


double x_offset;
double y_offset;
double z_offset;

Sets the tool component's X,Y,Z offset to the specified values.

73
VERICUT Development Tools

void cmeapi_set_var(variable, data_type, text_value, numeric_value);


char *variable;
double data_type;
char *text_value
double numeric_value;

Sets the nc variable specified by the first argument to either the double value of the fourth
argument or the text value of the third argument. The second argument contains the data
type (1 for number, 2 for text).

void cmeapi_set_word_string(text_str);
char *text_str;

Passes a textt string back to the tokenize logic. This is used while processing conditional
macros. Currently it is only used to pass a function name that is to be executed if the
conditional macro evaluates to be a function.

void cmeapi_siemens_last_nurbs_line();
This routine is a siemens specific routine which takes a peek at the next line to determine
if the current line is the last line of the NURBS statement. It returns 0 if the NURBS
statement continues on the next line, and returns 1 if the current line is the last line of the
NURBS statement.

void cmeapi_siemens_parse_poly_args(textstr, val1, val2, val3);


char *textstr;
double val1;
double val2;
double val3;

This routine is a siemens specific routine which parses a text string and returns 3 values.

double cmeapi_string_in_buffer(string, buffer);


char *string;
char *buffer;

Returns a 1 if the string is within the buffer, and returns 0 if it is not.

74
VERICUT Development Tools

char *cmeapi_substitute_wordvalue(block_type, f_word, f_value_string,


f_new_value_flag, x_word, w_value_string, x_new_value_flag, y_word,
y_value_flag, y_new_value_flag, z_word, z_value_string, z_new_value_flag,
s_word, s_word_value_string, s_new_value_flag);
double block_type;
char *f_word;
char *f_value_string;
double f_new_value_flag;
char *x_word;
char *x_value_string;
double x_new_value_flag;
char *y_word;
char *y_value_string;
double y_new_value_flag;
char *z_word;
char *z_value_string;
double z_new_value_flag;
char *s_word;
char *s_value_string;
double s_new_value_flag;

Substitutes word/value pairs into the existing input block. If the specified word is not
found in the input block, and this is a new value for this word, the new word/value string
will be concatenated to the original input block (before any comments or end of block
characters). The resulting string is returned.

NOTE: This routine now makes use of the block_type (first, middle, last) to determine
whether the sequence number and the after motion word/value pairs should be included
in the output block.

void cmeapi_sync_transfer();
This function is only used when running dual heads in synchronous mode. While in
synchronous mode, 1 head is in control. This function transfer the control to the other
head.

75
VERICUT Development Tools

void cmeapi_tool_load(tool_number, tool_component_name);


double tool_number;
char *tool_component_name;

Loads a tool. The tool_number is specified in the first argument. If the


tool_component_name is present, the tool will be loaded to onto that component. If it is
not present, the tool will be loaded onto the currently active tool component.

void cmeapi_user_abort_processing(message);
char *message;

This function stops the current processing of the MCD file, and prints an informational
message (if a message is specified).

76

Anda mungkin juga menyukai