UG帮助文档NXOPEN C#
更新时间:2023-10-28 21:52:01 阅读量: 综合文库 文档下载
- ug帮助文档电子版推荐度:
- 相关推荐
C#(UG)
NXOPEN Create and display a dialog
Private dialog As nxopen.uistyler.Dialog
dialog = UI.GetUI().Styler.CreateStylerDialog(\
显示对话框
dialog.Show()
Alternatively, the UI Styler uses the following instead of the show function you open the dialog from the menu:
或者,UI/Styler用以下代码实现从菜单打开的对话框的显示功能。
Dim isTopDialog As Boolean isTopDialog = false
dialog.RegisterWithUIMenu(isTopDialog)
How styler items are declared:
Private changeDialog As NXOpen.UIStyler.DialogItem Private changeStr0 As NXOpen.UIStyler.StringItem Private changeReal6 As NXOpen.UIStyler.RealItem How styler items are initialized: (初始化)
changeDialog = theDialog.GetStylerItem(\NXOpen.UIStyler.Dialog.ItemType.DialogItem)
changeStr0=theDialog.GetStylerItem(\ringItem)
changeReal6=theDialog.GetStylerItem(\.RealItem)
Register dialog box item callback functions
In order to register these callbacks, NX provides an API “Add##Handler”, where ## is replaced with “Activate”, “Construct”, “Apply” as shown in following examples. For more information on callbacks of all the dialog items, see the callback section in Dialog Item Reference.
When you exit a Styler dialog box normally, the destructor callback is executed at last. Selecting Cancel or OK will invoke Cancel or OK callback first, followed by the destructor callback.
Event Handler representation(事件处理程序代表)
In case of .NET (VB/C#) APIs, registration is done through Delegates, and represented as:
namespace NXOpen.UIStyler { }
In your C# application, the registration will look like this:
changeDialog.AddConstructHandler(AddressOf constructor_cb, False) changeDialog.AddOkayHandler(AddressOf ok_cb, False) changeDialog.AddApplyHandler(AddressOf apply_cb, False) changeStr0.AddActivateHandler(AddressOf bend_radius_cb, False) changeReal6.AddActivateHandler(AddressOf tolerance_cb, False)
public class StringItem: UIStyler.StylerItem { }
public delegate int Activate(UIStyler.StylerEvent eventObject); public unsafe void
AddActivateEvent(UIStyler.PushButton.Activate activateevent)();
Get and set dialog item attributes
The NX Open API provides get and set methods for the relevant attributes of each dialog item. You can set and get the visibility for a PushButton using the following code. Once you get the dialog item, you can set the property of the item anywhere in your program. Here “thePushButton0” is an object of PushButton dialog item. C#
/*Getting visibility attribute*/
Boolean isVisible = thePushButton0.Visibility;
/*Setting visibility attribute*/
thePushButton0.Visibility = true;
Launch a dialog from the event callback of another dialog
While registering a callback, you must determine whether this event can launch another dialog box, depending upon the value of the toggle for “Creates Dialog” on the resource editor. The last argument in every callback registering function indicates this. It is done by setting this argument to “TRUE” or “FALSE”. ?
C#
changeAction0 =
(NXOpen.UIStyler.PushButton)theDialog.GetStylerItem(\Dialog.ItemType.PushButton);
changeAction0.AddActivateHandler(new NXOpen.UIStyler.PushButton.Activate (action_0_act_cb), true); changeAction1 =
(NXOpen.UIStyler.PushButton)theDialog.GetStylerItem(\Dialog.ItemType.PushButton);
changeAction1.AddActivateHandler(new NXOpen.UIStyler.PushButton.Activate (action_1_act_cb), false);
Run a VB application as a journal script
1. 2. 3.
Choose Tools→Journal→Play. The Journal Manager dialog box opens. Click Browse to navigate to the location of the VB file. Click Run.
Run a VB application using DLL
1. 2. o o
Open Microsoft Visual Studio .Net. Create a new project:
Choose File→New→Project.
Select Visual Basic Projects, Console Application and type the name with
which you want to save the project (for example, test). o
Click OK.
3. In the Solution Explorer, select the AssemblyInfo.vb file from the project, right-click and choose Delete from the shortcut menu. A dialog appears warning you that the file will be permanently removed. Click OK.
4. In the Solution Explorer, select theModule1.vb file from the project, right-click and choose Delete from the shortcut menu. A dialog appears warning you that the file will be permanently removed. Click OK.
5. o o o o
Add references for the following files:
NXOpen.dll NXOpenUI.dll NXOpen.Utilities.dll NXOpen.UF.dll
In the Solution Explorer, right-click References under the project. Choose Add Reference→Browse→%UGII_ROOT_DIR%\\out\\managed. Press the CTRL key and select the dlls. 6.
In the Solution Explorer, highlight the project name, right-click and choose Add Existing Item. Navigate to the location of the .vb file and add it. 7.
Choose Project Menu→Properties. If you see \t, push down list, select Startup Project as the new Module name displayed in the list. Click OK. 8.
Choose Build Menu→Build Solution, or Ctrl + Shift + B, or go to Solution Explorer, select the project name, right-click and select Build. This creates the required dll. 9. o
To run the VB examples, do the following:
Choose File→Execute→NX Open. The Execute User Function dialog
box opens. o
Navigate to the location of the .dll file. It will be in the
directory under the directory named for the VB project. o
Select the .dll file and click OK.
Selection
Selection class contains methods that update the selection structure associated with the active dialog box. Some method declarations for class Selection are: namespace NXOpen {
class Selection
void SetSelectionMask (
NXOpen::SelectionHandle * select /** Selection handle */, NXOpen::Selection::SelectionAction action /** Mask action */,
const std::vector
public: void SetSelectionCallbacks (
NXOpen::SelectionHandle * select /** Selection handle */, const NXOpen::Selection::FilterCallback& filterproc /** Filter callback for additional user specific filtering. */,
const NXOpen::Selection::SelectionCallback& selcb /** Selection callback for application specific processing. */ );
C#
?
To get the selection handle
Dim selectH As SelectionHandle = changeDialog.GetSelectionHandle() ? ? ? ? ? ?
Create selection mask array
Dim selectionMask_array(0) As NXOpen.Selection.MaskTriple With selectionMask_array(0)
.Type = NXOpen.UF.UFConstants.UF_solid_type
.Subtype = NXOpen.UF.UFConstants.UF_solid_edge_subtype
.SolidBodySubtype = NXOpen.UF.UFConstants.UF_UI_SEL_FEATURE_ANY_EDGE End With ? ?
Set the selection mask
UI.GetUI().SelectionManager.SetSelectionMask(selectH,
NXOpen.Selection.SelectionAction.ClearAndEnableSpecific, selectionMask_array) ? ?
Set selection procedures
UI.GetUI().SelectionManager.SetSelectionCallbacks(selectH, AddressOf filter_cb, AddressOf sel_cb) ?
Define the filter_cb and sel_cb procedures as follows in order to register this in set selection procedure in the above step. ? ? ? ? ?
Public Function filter_cb(ByVal selectedObject As NXObject, ByVal selectionMask_array As NXOpen.Selection.MaskTriple, ByVal selectHandle As SelectionHandle) As Integer Try
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
// write your code here
Catch ex As NXException
' ---- Enter your exception handling code here ----- MsgBox(ex.Message) End Try End Function
Public Function sel_cb(ByVal selectedObjects As NXObject(), ByVal deselectedObjects() As NXObject, ByVal selectHandle As SelectionHandle) As Integer Try
// write your code here
Catch ex As NXException
' ---- Enter your exception handling code here ----- MsgBox(ex.Message) End Try
sel_cb = NXOpen.UIStyler.DialogState.ContinueDialog End Function
Dialog box layout
Introduction
Attachment class is used to set the attachment of the dialog item, for example left item, right item, top item, and so on and also the relative positioning of the item (for example, center, left, right, bottom, top). The following sections explain the corresponding NX Open APIs that manipulate the dialog item’s attachment (layout) structure.
Set an attachment to dialog Item
Following set of APIs are used to set the attachment for a particular dialog box item
C#
Attachment attach = changeAction0.InitializeAttachment(); attach.SetCenter(false);
attach.SetAttachTypeTop(Attachment.AttachType.Dialog); attach.SetTopDialogItem(\attach.SetTopOffset(0);
attach.SetAttachTypeRight(Attachment.AttachType.Dialog); attach.SetRightDialogItem(\attach.SetRightOffset(50);
attach.SetAttachTypeLeft(Attachment.AttachType.Dialog); attach.SetLeftDialogItem(\attach.SetLeftOffset(50);
changeAction0.SetAttachment(attach);
正在阅读:
UG帮助文档NXOPEN C#10-28
地产常识300例04-15
中华人民共和国著作权法(2010年第二次修订版,中英文对照)01-28
韩非子的管理思想09-19
2014年高考福建文综地理试卷及解析 高清版 - 图文10-01
DELL - vostro-2421 - 拆机详解 - 图文10-19
cs5530代码12-20
房地产销售案场精细化管理及项目热销关键点深度剖析-中房商学院09-07
五管要害部位检查标准(部位分项)09-30
- 多层物业服务方案
- (审判实务)习惯法与少数民族地区民间纠纷解决问题(孙 潋)
- 人教版新课标六年级下册语文全册教案
- 词语打卡
- photoshop实习报告
- 钢结构设计原理综合测试2
- 2014年期末练习题
- 高中数学中的逆向思维解题方法探讨
- 名师原创 全国通用2014-2015学年高二寒假作业 政治(一)Word版
- 北航《建筑结构检测鉴定与加固》在线作业三
- XX县卫生监督所工程建设项目可行性研究报告
- 小学四年级观察作文经典评语
- 浅谈110KV变电站电气一次设计-程泉焱(1)
- 安全员考试题库
- 国家电网公司变电运维管理规定(试行)
- 义务教育课程标准稿征求意见提纲
- 教学秘书面试技巧
- 钢结构工程施工组织设计
- 水利工程概论论文
- 09届九年级数学第四次模拟试卷
- C#
- 文档
- 帮助
- NXOPEN
- 长安客音乐广播剧社社团申请书 - 图文
- 汉寿李国保 汉寿县中小学大课间活动开展现状调查研究
- 企业负责人,安管人员安全培训题库(公共安全管理知识)
- 粗苯操作规程
- 书法文献学整理
- c语言期末复习题
- 食品安全重要性
- 对于中国保险业现状的分析
- 江苏省建设工程造价管理法律法规知识竞赛
- 水作文之人畜饮水申请报告
- 城市房屋拆迁跟踪审计操作程序
- 手掌上能判断疾病的14条线 - 图文
- 浅谈工程项目中施工监理的作用
- 课堂新坐标(教师用书)高中数学 3.1.3+4 空间向量基本定理 空间向量的坐标表示课后知能
- 目标责任书--医院医疗质量管理与考核标准及奖惩 - 图文
- 定语从句的考点集汇
- 中国居民膳食营养推荐摄入量
- 东北农大资产评估试题及答案
- 220kV组合开关GIS技术规范书
- CAD大纲