Development Tools
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.
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 *);
1
OptiPath API
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".
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);
int opapi_get_turning_contact_profile(int*, int**, sOPAPI_PROFILE **);
2
OptiPath API
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.
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
OptiPath API
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 *);
4
OptiPath API
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.
5
OptiPath API
Utility Functions
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
OptiPath API
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.
Get 2D tool and stock contact profile for turning operation. A 2D profile is represented
by an array of 2D profile element (sOPAPI_PROFILE). Each 2D profile element is the
position of either an arc center or a point. Function returns total number of profile
elements in all loops of the contact profile.
Parameters:
num_loops: Output, number of closed loops in contact profile.
size: Output, an array of number of profile elements for each closed loop, needs to be
freed by calling routine.
profile: Output, an array of all profile elements of contact profile, needs to be freed
by calling routine.
7
OptiPath API
OPAPI_NURBS = 2,
OPAPI_RAPID= 3,
}eOPAPI_MOTION_TYPE;
{
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;
{
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 */
8
OptiPath API
Parameters:
data : Input, memory pointer.
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.
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.
9
OptiPath API
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)
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).
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 *).
10
OptiPath API
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).
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.
Parameters:
rec_num : Output, current record number(line number) in toolpath file.
record : Output, current toolpath record being processed.
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.
11
OptiPath API
Parameters:
rpm : Input, spindle speed in rpm.
Parameters:
distance : Input, optimization distance.
12
CME-API
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
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.
1
CME-API
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.
2
CME-API
/* ************************************************************************** */
#define DllExport _declspec(dllexport)
/* ************************************************************************** */
DllExport void cmeapi_init(void)
{
printf("cmeapi_init() Success!\n");
cmeapi_register_macro("UserCheckSpindle", cms_UserCheckSpindle);
}
3
CME-API
This section describes how to build a DLL in Visual Studio Express C++.
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.
4
CME-API
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.
5
CME-API
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:
6
CME-API
This function is called when the DLL is loaded. You must define this functions in your
DLL.
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);
}
7
CME-API
The following functions were converted from the CGTech Macro Language:
void cmeapi_abort_processing();
Causes immediate, normal termination of machine code block processing.
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);
8
CME-API
void cmeapi_add_nurbs_knot(knot);
double knot;
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.
9
CME-API
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.
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.
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
10
CME-API
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();
Calculates the normal to the specified motion plane relative to the part.
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.
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.
11
CME-API
Returns 1 if the specified component is on the tool side of the machine, and returns 0 if it
is not.
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_offset(char *, char *, double);
void cmeapi_set_tool_length_offset(z_offset);
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.
12
CME-API
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);
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.
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.
13
CME-API
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();
14
CME-API
void cmeapi_init_nurbs();
double cmeapi_nurbs_get_next_point(xval, yval, zval);
void cmeapi_set_nurbs_order(order);
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;
double cmeapi_get_block_sequence();
Returns the current block sequence count (the total number of blocks that has been
processed.
15
CME-API
CMEAPI_POINT *cmeapi_get_c_3d_vars(double);
double variable;
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:
CMEAPI_AXIS *cmeapi_get_c_axis_vars(double);
double variable;
16
CME-API
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:
17
CME-API
double cmeapi_get_c_numeric_vars(variable);
double variable;
18
CME-API
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
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:
19
CME-API
CMS_C_EPSILON:
CMS_C_ANGLE_EPSILON:
CMS_C_TANGENT_EPSILON:
CMS_C_MAZAK_PART_LOADER_CNT:
20
CME-API
21
CME-API
char *cmeapi_get_c_text_vars(variable);
double variable:
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.
Index 2:
char *= "10+5"
value = 15
argtype = 1
Index 3:
char *= "test"
value = 0
argtype = 2 (text argument)
22
CME-API
Index -1:
char *= "1"
value = 1
argtype = 1 (???)
The special argument is the argument that comes after the ";".
char *cmeapi_get_current_input_filename(void)
23
CME-API
double cmeapi_get_file_id();
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.
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.
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.
24
CME-API
double cmeapi_get_guide_z_distance();
Returns the vertical distance between the guides.
char *cmeapi_get_inch_format(word);
char *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();
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();
char *cmeapi_get_input_block(void);
Returns the current block.
25
CME-API
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);
char *cmeapi_get_macro_modal(modal_name);
char *modal_name;
See also:
void cmeapi_get_last_token(double *, char *);
char *cmeapi_get_metric_format(word);
char *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();
26
CME-API
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.
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;
See also:
double cmeapi_format_number(format, type, value);
27
CME-API
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();
char *cmeapi_get_input_block(void);
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.
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 an array of values for the nc variables beginning from start index and ending at
end index.
28
CME-API
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.
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.
29
CME-API
double cmeapi_get_opti_block_type(void);
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.
int cmeapi_get_program_record(void)
Returns the line number of the record currently being processed in the NC program file.
double cmeapi_get_programming_method();
Returns the programming method (0 for tool tip, 1 for gage length, and 2 for tool length
compensation).
30
CME-API
Returns a series of information associated with RAPID motion for the specified
component.
CMEAPI_VECTOR *cmeapi_get_tool_axis();
CMEAPI_POINT cmeapi_get_tool_axis_position(tool_name);
char *tool_name;
31
CME-API
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;
};
double cmeapi_get_tool_gage_length(void)
Returns the length of the active tool component as measured from the zero point of the
tool to the gage_line.
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.
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);
32
CME-API
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.
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.
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.
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);
33
CME-API
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.
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;
34
CME-API
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.
The first argument is a "command" argument indicating whether to initialize the iteration,
or to return the next iterative point on the arc. The center point and normal vector of
plane passing through start point and center point are passed in the second and third
arguments. The fourth, fifth and sixth arguments specify the start point, the end point and
the radius of the arc respectively. Tolerance, which is used to calculate the number of
chords, is specified in the seventh argument. The function returns the number of chords
remaining for arc iteration, and also returns next iterative point on the arc in eighth
argument.
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.
35
CME-API
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;
void cmeapi_max_warnings(max_warnings);
double max_warnings;
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
Minute" and is used to calculate RPM when the spindle is in Constant Surface Speed
mode.
36
CME-API
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.
37
CME-API
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..
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.
38
CME-API
39
CME-API
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;
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.
40
CME-API
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.
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.
41
CME-API
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.
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;
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);
42
CME-API
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.:
43
CME-API
double k;
double r;
double i_present;
double j_present;
double k_prsent;
double r_present;
double pitch;
Sets the values in the Work Offsets table. The index is the Register in the Work Offsets
table.
44
CME-API
45
CME-API
Sets the text value of a specific variable. See char* cmeapi_get_c_text_vars() for a list of
supported variables.
46
CME-API
Sets the values associated with the specified typeII argument. If index is set to -1, the
type II special argument is returned.
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
supported, and switch_values are the current value for each switch (0 for OFF, and 1 for
ON).
47
CME-API
Sets the specified color. The name of the component that color appllies to, is specified in
first argument. The color index is specified in the second argument.
NOTE: The color_index value refers to the number associated with the color in the
Shade Color list on the Color window , Define tab. See Color window, Define tab in the
the Edit Menu section of VERICUT Help for additional information.
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_cycle_component(component_register_name);
char *component_register_name;
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.
Passes the current feedrate to Machine Simulation. This is typically used to set the
corresponding status field.
48
CME-API
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();
49
CME-API
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_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);
50
CME-API
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.
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;
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);
51
CME-API
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.
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 above values can be added together. For example: A value of 5 specifies that the
destination is both the output file and the screen.
52
CME-API
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);
double 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 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).
53
CME-API
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.
This routine is a siemens specific routine which parses a text string and returns 3 values.
54
CME-API
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.
void cmeapi_tool_load(double);
double tool_number
Loads a tool. The tool_number is specified in the first argument. The tool will be loaded
on to 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).
55