购买与咨询 NX 二次开发视频教程,请联系微信号:13890821008 QQ号:85585969
C header: NXOpenDLL.h
#include <stdio.h>
#include <uf.h>
#include <uf_ui.h>
double dec2rad(double dNumber);
double rad2dec(double dNumber);
double GetBaseDia(double dDiameter, double dHeight, double dAngle);
#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
static int report_error(char *file, int line, char *call, int irc)
{
if (irc)
{
char err[133], msg[133];
sprintf(msg, "*** ERROR code %d at line %d in %s:\n+++ ", irc, line, file);
UF_get_fail_message(irc, err);
UF_print_syslog(msg, FALSE);
UF_print_syslog(err, FALSE);
UF_print_syslog("\n", FALSE);
UF_print_syslog(call, FALSE);
UF_print_syslog(";\n", FALSE);
if (!UF_UI_open_listing_window())
{
UF_UI_write_listing_window(msg);
UF_UI_write_listing_window(err);
UF_UI_write_listing_window("\n");
UF_UI_write_listing_window(call);
UF_UI_write_listing_window(";\n");
}
}
return (irc);
}
C source: NXOpenDLL.c
#include <stdio.h>
#include <stdlib.h>
#include <uf.h>
#include <uf_ui.h>
#include "NXOpenDLL.h"
#include <uf_mom.h>
#include <uf_cutter.h>
#include <uf_ncgroup.h>
#include <uf_setup.h>
#include <math.h>
/*****************************************************************************
** Activation Methods
*****************************************************************************/
/* Explicit Activation
** This entry point is used to activate the application explicitly, as in
** "File->Execute UG/Open->User Function..." */
extern DllExport void ufusr(char *parm, int *returnCode, int rlen)
{
int iStackCount, iSections, iCounter;
char cToolName[UF_OBJ_NAME_LEN + 1], cIndex[10];
const char *pcToolName;
tag_t tNCRoot = NULL_TAG, tTool = NULL_TAG, tSetup = NULL_TAG;
UF_MOM_id_t tMOMid;
UF_CUTTER_holder_section_t **tStackDataArray;
/* Initialize the API environment */
if (UF_CALL(UF_initialize()))
{
/* Failed to initialize */
return;
}
UF_print_syslog("Executing Holder Info DLL ...\n", FALSE);
UF_CALL(UF_MOM_ask_mom(parm, &tMOMid));
UF_CALL(UF_MOM_ask_string(tMOMid, "tool_name", &pcToolName));
strcpy(cToolName, pcToolName);
UF_CALL(UF_SETUP_ask_setup(&tSetup));
UF_CALL(UF_SETUP_ask_mct_root(tSetup, &tNCRoot));

●●●请先
登陆 或
注册 后查看●●●
TCL code:
global mom_JH_stack_count mom_JH_holder_diameter mom_JH_holder_angle mom_JH_holder_hight
MOM_run_user_function "[MOM_ask_env_var UGII_INITIAL_UFUN_DIR]GetToolHolderInfo.dll" ufusr