15757753770 发表于 2015-10-28 19:20:40

UF写ug宏文件并启动

UF写ug宏文件并启动

UG二次开发群 51061704
乐清市-梅雷-QQ1821117007

#include <windows.h>
#include <shellapi.h>
#include <iostream>   
#include<fstream>
using namespace std;
#pragma comment(lib, "User32.lib") //VS编译器必须加这行


      /* TODO: Add your application code here */



//写ug宏文件
ofstream SaveFile("D:\\NX+\\startup\\MEILEI_UG_MACRO.macro");
SaveFile << "NX 4.0.0.25\n";
SaveFile << "Macro File: D:\\NX+\\startup\\MEILEI_UG_MACRO.macro\n";
SaveFile << "Macro Version 7.50\n";
SaveFile << "Macro List Language and Codeset: simplified chine 13\n";
SaveFile << "Created by Administrator on Wed Sep 16 13:13:26 2015\n";
SaveFile << "Part Name Display Style: $FILENAME\n";
SaveFile << "Selection Parameters 1 2 0.305691 1\n";
SaveFile << "Display Parameters 1.000000 17.138889 8.262992 -1.000000 -0.482119 1.000000 0.482119\n";
SaveFile << "*****************\n";
SaveFile << "RESET\n";
SaveFile << "MENU, 0, UG_TOOLS_CUSTOMIZE UG_GATEWAY_MAIN_MENUBAR <SelectionBar> ## !\n";
SaveFile.close();


Sleep(200); //延迟 1000=1秒


//如果是64位的自己修改下宏函数名就行
//32位调宏函数名:?MACRO_playback_from_usertool@@YAXPBD@Z
//64位调宏函数名:?MACRO_playback_from_usertool@@YAXPEBD@Z


//API调用UG的宏
typedef void (*load_ufusr_f_p_t)(char* param, int* retcode, int paramLen);
load_ufusr_f_p_t load_ufusr_ptr = NULL;
char* file_path = "F:\\NX4.0XP\\UGII\\libugui.dll";

UF_load_library (file_path, "?MACRO_playback_from_usertool@@YAXPBD@Z", (UF_load_f_p_t *) & load_ufusr_ptr);

if (load_ufusr_ptr != NULL)
{
int retcode;
load_ufusr_ptr("D:\\NX+\\startup\\MEILEI_UG_MACRO.macro", &retcode, 1);
}


      /* Terminate the API environment */

穿着隐身的马甲* 发表于 2017-9-14 10:19:30

{:handshake:}

youlanblue 发表于 2019-8-20 10:36:12

楼主你好,我想问一下可否通过批处理运行NX,并调用宏来实现参数化模型的自动更新?

qqq19303 发表于 2024-3-5 22:37:31

6666666666666

复仇云 发表于 2024-3-6 12:41:19

感谢分享
页: [1]
查看完整版本: UF写ug宏文件并启动