NXOpen UG二次开发

本文详细介绍了如何在UG中创建自定义菜单,包括安装UG版本、创建启动文件夹和模具.men文件,以及通过编程添加主菜单和子菜单。重点讲解了如何设计对话框,如知识检索、方案推荐和属性赋值,并展示了如何调用MFC应用和管理参数。

一、创建ug菜单

1、安装ug110.0版本

2、在Program Files\Siemens\NX 10.0\TKLTOOLS目录下创建“startup”文件夹,在文件夹中创建“模具.men”文件

3、添加代码

VERSION 120
EDIT UG_GATEWAY_MAIN_MENUBAR         //编辑ug的主菜单

AFTER UG_HELP                 		 //在help后面添加
	CASCADE_BUTTON moju  			 //定义ID 
	LABEL 模具  					    //标签名字(显示的名字)
END_OF_AFTER

MENU moju   						 //设计ID为moju的子菜单
BUTTON 111  						 //定义第一个按钮的ID
LABEL 知识检索  					  //标签名字(显示的名字)
BITMAP       						 //可以添加图案
ACTIONS webjiansuo 					 //需要链接的dll文件名(dll文件为点击该按钮后弹出的对话框)

BUTTON 222
LABEL 方案推荐
BITMAP
ACTIONS FangAnTuiJian

BUTTON 333
LABEL 人工审核
BITMAP
ACTIONS evaluate

END_OF_MENU   

​ 4、添加环境变量

​ [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-GmQPZMaB-1657869876988)(C:\Users\123\Desktop\1.png)]

二、设计对话框

1、打开ug,点击:新建–>确定–>启动–>所有应用模具–>块UI样式编辑器。

2、设计对话框的样式,按钮,下拉框,显示的内容等。

3、 设计完成后,点击:代码生成,语言选择c++

4、点击:文件–>保存,选择保存路径,点击:OK。会保存后缀分别为“.dlx”, ".h"和“.cpp”的文件

三、编辑对话框

1、打开visual studo软件,新建项目,选择NX10 NXopen Wizard 点击新建;

2、新建完成后删除存在的cpp文件,将第二步生成的“.h”和“.cpp”添加到新建的项目中。弹出的对话框中语言选择c++;下一步选择

Automatically (ufsta) 和Automatically, when the NX session terminates ;点击完成。

3、在“.h”中引入头文件

#include <Windows.h>

#ifdef CreateDialog
#undef CreateDialog
#endif


#include <uf.h>
#include <uf_ui.h>
#include <uf_exit.h>
#include <uf_defs.h>
#include <NXOpen/NXException.hxx>
#include <NXOpen/ModelingView.hxx>
#include <NXOpen/ModelingViewCollection.hxx>
#include <NXOpen/Part.hxx>
#include <NXOpen/PartCollection.hxx>
#include <uf_ui.h>
#include <uf_ui_ugopen.h>
#include <uf.h>
#include <NXOpen/Session.hxx>
#include <NXOpen/UI.hxx>
#include <NXOpen/selection.hxx>
#include <NXOpen/Features_Feature.hxx>
#include <NXOpen/ListingWindow.hxx>
#include <uf_obj.h>
#include <uf_attr.h>
#include <uf_cfi.h>
#include <uf_curve.h>
#include <uf_modl_primitives.h>
#include <stdlib.h>
#include <uf_modl.h>

#include <uf_defs.h>
#include <uf_ui_types.h>
#include <iostream>
#include <NXOpen/Session.hxx>
#include <NXOpen/UI.hxx>
#include <NXOpen/NXMessageBox.hxx>
#include <NXOpen/Callback.hxx>
#include <NXOpen/NXException.hxx>
#include <NXOpen/BlockStyler_UIBlock.hxx>
#include <NXOpen/BlockStyler_BlockDialog.hxx>
#include <NXOpen/BlockStyler_PropertyList.hxx>
#include <NXOpen/BlockStyler_Enumeration.hxx>
#include <NXOpen/BlockStyler_Group.hxx>
#include <NXOpen/BlockStyler_Button.hxx>


#include <uf_defs.h>
#include <NXOpen/NXException.hxx>
#include <NXOpen/Session.hxx>
#include <NXOpen/Assemblies_AssembliesGeneralPropertiesBuilder.hxx>
#include <NXOpen/Assemblies_AssembliesParameterPropertiesBuilder.hxx>
#include <NXOpen/Assemblies_Component.hxx>
#include <NXOpen/Assemblies_ComponentAssembly.hxx>
#include <NXOpen/Assemblies_SelectComponentList.hxx>
#include <NXOpen/AttributeManager.hxx>
#include <NXOpen/AttributePropertiesBaseBuilder.hxx>
#include <NXOpen/AttributePropertiesBuilder.hxx>
#include <NXOpen/BasePart.hxx>
#include <NXOpen/Builder.hxx>
#include <NXOpen/DateBuilder.hxx>
#include <NXOpen/DateItemBuilder.hxx>
#include <NXOpen/DateItemBuilderList.hxx>
#include <NXOpen/Expression.hxx>
#include <NXOpen/MassPropertiesBuilder.hxx>
#include <NXOpen/NXObject.hxx>
#include <NXOpen/ObjectGeneralPropertiesBuilder.hxx>
#include <NXOpen/Part.hxx>
#include <NXOpen/PartCollection.hxx>
#include <NXOpen/PropertiesManager.hxx>
#include <NXOpen/SelectNXObjectList.hxx>
#include <NXOpen/SelectObjectList.hxx>
#include <NXOpen/Session.hxx>
#include <NXOpen/Update.hxx>
#include <NXOpen/NXObjectManager.hxx>

四、在“.cpp"中添加添加属性函数

1、方案评估代码

void messaage()函数 //给对象添加属性

/* Initialize the API environment */
	if (UF_CALL(UF_initialize()))
	{
		return;
	}

	//获取所选择对象的标签
	tag_t tagUnderFace = 0;
	std::vector<TaggedObject*>objects = this->selection0->GetProperties()->GetTaggedObjectVector("SelectedObjects");
	for (int i = 0; i<ob
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值