许可优化
许可优化
产品
产品
解决方案
解决方案
服务支持
服务支持
关于
关于
软件库
当前位置:服务支持 >  软件文章 >  NXOpen UG二次开发入门指南

NXOpen UG二次开发入门指南

阅读数 9
点赞 0
article_banner

一、创建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
免责声明:本文系网络转载或改编,未找到原创作者,版权归原作者所有。如涉及版权,请联系删


相关文章
技术文档
QR Code
微信扫一扫,欢迎咨询~
customer

online

联系我们
武汉格发信息技术有限公司
湖北省武汉市经开区科技园西路6号103孵化器
电话:155-2731-8020 座机:027-59821821
邮件:tanzw@gofarlic.com
Copyright © 2023 Gofarsoft Co.,Ltd. 保留所有权利
遇到许可问题?该如何解决!?
评估许可证实际采购量? 
不清楚软件许可证使用数据? 
收到软件厂商律师函!?  
想要少购买点许可证,节省费用? 
收到软件厂商侵权通告!?  
有正版license,但许可证不够用,需要新购? 
联系方式 board-phone 155-2731-8020
close1
预留信息,一起解决您的问题
* 姓名:
* 手机:

* 公司名称:

姓名不为空

姓名不为空

姓名不为空
手机不正确

手机不正确

手机不正确
公司不为空

公司不为空

公司不为空