点击查看详细介绍

使用后置处理API函数查找项目以获取当前刀具 UF_MOM_ask_mom UF_MOM_ask_string

nxopen 4月前 479 4

UG NX 二次开发(C、C#、WPF)技术交流群:641226372      UG二次开发(C、C#、WPF)


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




1

最新回复 (4)
  • qwerty 4月前
    1

    GOOD ,THANK YOU

  • 沉默的兔子 4月前
    2

    GOOD ,THANK YOU

  • tianmu1972 2月前
    3

    很有启发,谢谢!

  • liang 17天前
    4

    GOOD ,THANK YOU

请登录后发表新帖