当前位置:文档之家› UG帮助文档NXOPEN C#

UG帮助文档NXOPEN C#

UG帮助文档NXOPEN C#
UG帮助文档NXOPEN C#

C#(UG)

Create and display a dialog

Private dialog As nxopen.uistyler.Dialog

dialog = UI.GetUI().Styler.CreateStylerDialog("Sample.dlg")

显示对话框

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("UF_STYLER_DIALOG_INDEX",

NXOpen.UIStyler.Dialog.ItemType.DialogItem)

changeStr0=theDialog.GetStylerItem("STR_0",NXOpen.UIStyler.Dialog.ItemType.St ringItem)

changeReal6=theDialog.GetStylerItem("REAL_6",NXOpen.UIStyler.Dialog.ItemType .RealItem)

Register dialog box item callback functions

In order to register these callbacks, NX provides an API “Add##Handler”, wh ere ## 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

{

public class StringItem: UIStyler.StylerItem

{

public delegate int Activate(UIStyler.StylerEvent eventObject);

public unsafe void

AddActivateEvent(UIStyler.PushButton.Activate activateevent)();

}

}

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)

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("ACTION_0",

Dialog.ItemType.PushButton);

changeAction0.AddActivateHandler(new NXOpen.UIStyler.PushButton.Activate

(action_0_act_cb), true);

changeAction1 =

(NXOpen.UIStyler.PushButton)theDialog.GetStylerItem("ACTION_1",

Dialog.ItemType.PushButton);

changeAction1.AddActivateHandler(new NXOpen.UIStyler.PushButton.Activate

(action_1_act_cb), false);

Run a VB application as a journal script

1. Choose Tools→Journal→Play. The Journal Manager dialog box opens.

2. Click Browse to navigate to the location of the VB file.

3. Click Run.

Run a VB application using DLL

1. Open Microsoft Visual Studio .Net.

2. Create a new project:

o Choose File→New→Project.

o 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. Add references for the following files:

o NXOpen.dll

o NXOpenUI.dll

o NXOpen.Utilities.dll

o 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 "Module1" in Startup Projec 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. To run the VB examples, do the following:

o 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 \bin 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 & mask_array /** Mask triples */

);

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("INT_1");

attach.SetTopOffset(0);

attach.SetAttachTypeRight(Attachment.AttachType.Dialog);

attach.SetRightDialogItem("UF_STYLER_DIALOG_INDEX");

attach.SetRightOffset(50);

attach.SetAttachTypeLeft(Attachment.AttachType.Dialog);

attach.SetLeftDialogItem("UF_STYLER_DIALOG_INDEX");

attach.SetLeftOffset(50);

changeAction0.SetAttachment(attach);

Revolve产品知识

产品名称BOSE SoundLink Revolve 产地墨西哥颜色灰/银 产品尺寸/重量 152×82×82mm/660g 续航时间 12小时 充电时间4小时 供电方式锂电池 音频接口 3.5mm/ USB接口(只限电脑音源)单元尺寸3英寸 NFC功能是 防水级别IPX4防水 通话功能是 语音提示是 APP 是 保修期一年(注册微信会员赠送延保6个月) 包装清单音箱本机x1 USB电源x1USB连接线 x1 交流电源适配器 x1 技术特点1360度全向发声:一个向下发声的全音域单元配合BOSE专利的声波导向技术,可以向四周发出均匀,无死角的声音 技术特点2独特优势:体积小巧 低音震撼 技术特点3优雅的设计:采用高品质阳极氧化铝金属材质配合全新的无缝连接一体成型工艺,是产品更为高雅,耐用 技术特点4蓝牙无线连接:方便,易用,可连接几乎是所有常规的智能手机,平板电脑的蓝牙设 备,可支持与蓝牙设备10米距离的无线连接。技术特点5内置锂电池:更好的便携性,4小时充满电可在正常音量下约12小时的使用时间。 技术特点6IPX4级防水:可以使您在室外环境中放心使用。技术特点7BOSE Connect APP :轻松实现“派对模式”与“立体声模式”的切换,可以满足您更多声音需求。技术特点8支持有线连接:3.5mm与USB接口可以满足你有线音源的连接,连接更多的设备。 技术特点9可选配充电底座:充电方便,同时为扬声器在家中使用时提供了一个放置的地方。 技术特点10 远程操作:可通过配对的蓝牙设备控制扬声器的各项功能(如音量等)不需要携带其他产品说明

音效表现 Feature令人惊艳的宏亮气势,超乎想象的小巧体积。Benefit体积小巧 低音震撼 Advantage 精巧的外壳下装载了众多技术,展现出扬声器超乎想象的的低音效能,让人深深的沉醉在饱满的动人音色中。 Evidence X先生经常会带着家中的小朋友到户外和同事们野餐,因为有小孩子每次外出都需要随身带很多东西。聚会时大家喜欢拿出手机播放孩子们喜欢的音乐增加气氛,偶尔路过门店体验到我们的产品,十分满意。不仅可以满足了他外出携带需要,还提供了完美的音质 360°音效 Feature 可以向四周发出均匀的,无死角的声音。实现零死角的环绕音效。 Benefit随意摆放,一样可以体验到全方位的声音。 Advantage 一个向下发声的全音域单元配合BOSE专利的声波导向器,营造出全方位,无死角的震撼 Evidence X女士三口之家,每天晚上喜欢在客厅给孩子放放音乐,孩子太小总是跑来跑去,之前的音响固定的放在一个位置声音太大影响邻居,声音太小孩子跑来跑去还听不见。选择了我们产品后放在家里中间的位置不管孩子 精致设计 Feature 一体成型的采用高品质阳极氧化铝金属材质配合全新的无缝连接一体成型工艺。 Benefit使产品更为高雅,耐用。 Advantage 精密的设计,一体成型的阳极氧化铝材质,可以提供全方位的音效,不留一丝缝隙,外 Evidence X小姐喜欢游泳,喜欢做SPA ,喜欢泡温泉,更喜欢听音乐。自从购买了产品,她可以随意带着音响到她喜欢的地方,再也没有任何的顾虑。无论什么环境,我们的产品都可以

python-ctypes模块中文帮助文档

内容: .加载动态链接库 .从已加载的dll中引用函数 .调用函数1 .基本的数据类型 .调用函数2 .用自己的数据类型调用函数 .确认需要的参数类型(函数原型) .返回值 .传递指针 .结构和联合 .结构或联合的对齐方式和字节的顺序 .结构和联合中的位 .数组 .指针 .类型转换 .未完成的类型 .回调函数 .访问dlls导出的值 .可变长度的数据类型 .bugs 将要做的和没有做的事情 注意:本文中的代码例子使用doctest确保他们能够实际工作。一些代码例子在linux和windows以及苹果机上执行有一定的差别 注意:一些代码引用了ctypes的c_int类型。它是c_long在32位机子上的别名,你不应该变得迷惑,如果你期望 的是c_int类型,实事上打印的是c_long,它们实事上是相同的类型。 加载动态链接库 ctypes加载动态链接库,导出cdll和在windows上同样也导出windll和oledll对象。 加载动态链接库后,你可以像使用对象的属性一样使用它们。cdll加载使用标准的cdecl调用约定的链接库, 而windll库使用stdcall调用约定,oledll也使用stdcall调用约定,同时确保函数返回一个windows HRESULT错误代码。这错误 代码自动的升为WindowsError Python exceptions,当这些函数调用失败时。 这有一些windows例子,msvcrt是微软的c标准库,包含大部分的标准c函数,同时使用cdecl调用约定。 注:cdecl和stdcall的区别请见https://www.doczj.com/doc/dc18130527.html,/log-20.html >>> from ctypes import * >>> print windll.kernel32 # doctest: +WINDOWS

CAD和TSSD快捷键(含探索者中文键名)

AutoCAD 简化命令 3A, *3DARRAY 3DO, *3DORBIT 3F, *3DFACE 3P, *3DPOLY A, *ARRAY ,阵列ADC, *ADCENTER AD, *ID AE, *AREA AL, *ALIGN AP, *APERTURE ATP, *ATTDISP AT, *DDATTE -AT, *ATTEDIT ATT, *DDATTDEF -ATT, *ATTDEF AV, *DSVIEWER B, *BREAK H, *BHATCH BL, *BMAKE -BL, *BLOCK BO, *BOUNDARY -BO, *-BOUNDARY CO, *COPY CC, *CHAMFER CH, *DDCHPROP -CH, *CHANGE DDC, *DDCOLOR C, *CIRCLE D, *DIM DD, *DDEDIT DDV, *DDVPOINT DI, *DIST DIV, *DIVIDE DO, *DONUT DST, *DIMSTYLE DT, *DTEXT DV, *DVIEW DX, *DDIM DXI, *DXFIN DXO, *DXFOUT E, *ERASE EL, *ELEV ELL, *ELLIPSE EN, *END EP, *EXPLODE EX, *EXTEND F, *FILLET FF, *FILL FI, *FILTER G, *GROUP GR, *DDGRIPS -GR, *GRID HI, *HIDE HE, *HATCHEDIT HT, *HATCH I, *DDINSERT -I, *INSERT IM, *IMAGE -IM, *-IMAGE L, *LINE LA, *LAYER -LA, *-LAYER LE, *LEADER LEN, *LENGTHEN LI, *LIST LS, *LTSCALE LT, *LINETYPE -LT, *-LINETYPE LTS, *LTSCALE M, *MOVE MA, *MATCHPROP ME, *MEASURE MI, *MIRROR ML, *MLINE MO, *DDMODIFY MN, *MENU MS, *MSPACE MT, *MTEXT -MT, *-MTEXT MV, *MVIEW N, *NEW O, *OFFSET OP, *OPEN OS, *OSNAP

python-os模块中文帮助文档

注此模块中关于unix中的函数大部分都被略过,翻译主要针对WINDOWS,翻译速度很快,其中很多不足之处请多多包涵。 这个模块提供了一个轻便的方法使用要依赖操作系统的功能。如何你只是想读或写文件,请使用open() ,如果你想操作文件路径,请使用os.path模块,如果你想在命令行中,读入所有文件的所有行,请使用 fileinput模块。使用tempfile模块创建临时文件和文件夹,更高级的文件和文件夹处理,请使用shutil模块。 os.error 内建OSError exception的别名。 https://www.doczj.com/doc/dc18130527.html, 导入依赖操作系统模块的名字。下面是目前被注册的名字:'posix', 'nt', 'mac', 'os2', 'ce', 'java', 'riscos'. 下面的function和data项是和当前的进程和用户有关 os.environ 一个mapping对象表示环境。例如,environ['HOME'] ,表示的你自己home文件夹的路径(某些平台支持,windows不支持) ,它与C中的getenv("HOME")一致。 这个mapping对象在os模块第一次导入时被创建,一般在python启动时,作为site.py处理过程的一部分。在这一次之后改变environment不 影响os.environ,除非直接修改os.environ. 注:putenv()不会直接改变os.environ,所以最好是修改os.environ 注:在一些平台上,包括FreeBSD和Mac OS X,修改environ会导致内存泄露。参考putenv()的系统文档。 如果没有提供putenv(),mapping的修改版本传递给合适的创建过程函数,将导致子过程使用一个修改的environment。 如果这个平台支持unsetenv()函数,你可以删除mapping中的项目。当从os.environ使用pop()或clear()删除一个项目时,unsetenv()会自动被调用(版本2.6)。 os.chdir(path) os.fchdir(fd) os.getcwd() 这些函数在Files和Directories中。

【资料】Airpak中文帮助文档(1.7部分)

Airpak中文帮助文档(1.7部分) 此文翻译来自Airpak帮助文档1.7部分 通过1.7部分,你将使用Airpak 建立一个问题、解决一个问题以及输出结果。这是 对Airpak 特点的基础介绍。 如有疑问可参考Airpak帮助文档的相关部分

1.7 示例 在下面的示例中,你将使用Airpak建立一个问题、解决一个问题以及输出结果。这是对Airpak特点的基础介绍。使用指南中的例子将提供更完整的程序特点。 1.7.1 问题描述 图1.7.1显示的所要解决的问题。房间中包含了一个开放的进风口、一个排气口和一个恒定温度的墙。房间的长是4.57 m,宽是 2.74 m,高是2.74m。房间外测量值是0.92 m ×0.46 m,同时引入一个冷空气射入房间使得空气流动。排气口的尺寸是0.91 m×0.45 m。惯性的力量、浮力的力量以及湍流混合的相互作用对所提供的空气的渗透及路径有着重要的影响。 1.7.2 主要的过程 图1.7.1显示的问题是一个稳定通风的情形。边界温度以及速度是被定义的。示例中的步骤简要如下: z打开和定义一项工作 z调整默认房间大小 z对于一个房间生成一个进风口(opening)、排气口(vent)以及墙 z生成网格 z计算

z检查结果 1.7.3 开始一个新工作 启动Airpak(1.5节)。图1.7.2.显示的是【Open job】面板。 在【Select the job to open】文本显示框中路径的最后将/sample写上。点击【Accept】打开一个新工作。Airpak将生成一个10 m×3 m×10 m默认房间,同时在图形窗口显示房间。 你可以使用鼠标左键围绕一个中心点旋转房间,或者使用鼠标中间键你可以将房间转移到屏幕的任意一点上。使用右键放大或缩小房间。为了将房间回复的默认方位,点击【Options】菜单下【Orient】,在下拉菜单中选择【Home】。 1.7.4 定义工作 通过定义房间的种类和设置环境温度来开始工作。这些参数在【Problem setup】面板中具体指明了。在【File】菜单中选择【Problem】可以打开【Problem setup】面板(如图1.7.3)。

pyevolve中文帮助文档

Pyevolve的用户手册中文版 1.1.6基本概念 Raw score:表示由适应度函数返回的还未进行比例换算的适应值。 Fitness score :对Raw score进行比例换算后的适应值,如果你使用线性的比例换算(Scaling.LinearScaling()),fitness score将会使用线性方法进行换算,fitness score代表个体与种群的相关程度。 Sample genome : 是所有genome进行复制的基础 1.2.3对pyevolve进行扩展 对pyevolve进行扩展首先要查看GenomeBase.GenomeBase类的源码。 扩展的基本步骤 1)创建染色体类 2)创建染色体的初始化函数 3)创建遗传算子:选择算子,交叉算子,和变异算子等。 1.3模块 1.3.2基本模块 a) Consts :常量模块 Pyevolve 提供了所有的默认遗传算子,这是为了帮助用户方便的使用API,在常量模块中,你可以找到这些默认的设置,最好的情况是查看常量模块,但是不改变常量模块中的内容。 b)Util :公用模块 公用模块中提供了一些公用的函数,比如列表项的交换,随机功能等。 list2DSwapElement(lst, indexa, indexb):交换矩阵中的元素项。 listSwapElement(lst, indexa, indexb):交换列表中的元素项。 c)FunctionSlot :函数分片模块 Pyevolve中广泛使用函数分片的概念;这个想法是很简单的,每个遗传操作或者说是任何遗传操作能够被分配到一个片,按照这种想法,我们能够添加不止一种的遗传操作,比如说同时进行两种或者更多的变异操作,或者两种或更多的计算操作等,函数分片模块是以FunctionSlot.FunctionSlot类来实现的。 例子: Def fit_fun(genome): …. Def fit_fun2(genome): …. Genome.evaluator.set(fit_fun) Genome.evaluator.add(fit_fun2) Print Genome.evaluator #the result is “slot [evaluator] (count:2)” Print Genome.evaluator[0] # the result is “function fit_fun at <....>” Print Genome.evaluator[1] # the result is “function fit_fun2 at <...>”

相关主题
文本预览
相关文档 最新文档