![](data/attachment/common/37/common_23_usergroup_icon.png)
少尉
UID2367596
![Rank: 5](template/yl5361_news_z1/image/star_level3.gif) ![Rank: 5](template/yl5361_news_z1/image/star_level1.gif)
U币1
G币2058
技术0
主题51
精华1
阅读权限75
注册时间2015-6-28
最后登录2021-3-13
在线时间69 小时
居住地浙江省 温州市 乐清市 乐成镇
QQ
手机15757753770
出生地辽宁省 大连市
![](data/attachment/common/37/common_23_usergroup_icon.png)
少尉
![Rank: 5](template/yl5361_news_z1/image/star_level3.gif) ![Rank: 5](template/yl5361_news_z1/image/star_level1.gif)
|
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 */
|
|