Workbench用户自定义控件界面显示类型

Workbench用户自定义控件界面显示类型
上一期我们演示了APDL命令封装为Mechanical用户自定义插件,在插件中,我们只能选择模型,设置float类型的数据。在实际使用中遇到情况会更复杂,比如通过下拉列表选择加载形式、选择载荷坐标系,选择文件等情况,本期我将介绍常见的界面定义方式,实现以下功能。
-
元素 <PropertyGroup>
将多个属性封装为一组属性
<propertygroup name="Group1" caption="Simple group with caption" display="caption">
<property name="Prop1" caption="Prop1" control="text" />
<property name="Prop2" caption="Prop2" control="text" />
<property name="Prop3" caption="Prop3" control="text" />
</propertygroup>
元素propertygroup 有一个特殊的属性display。当display设置为caption,表示所有子属性都显示在标题下。如果省略caption,display默认为hidden,表示属性组隐藏.
2. 通过Group Select属性选择,确定属性的显示与隐藏。
<propertygroup name="Group2" caption="Another group" display="caption">
<propertygroup name="Group3" caption="Group Select" display="property" control="select" default="Option 1">
<attributes options="Option 1,Option 2,Option 3" />
<property name="Prop1" caption="Prop For Option 1" visibleon="Option 1" control="text" />
<property name="Prop2" caption="Prop For Option 1 and Option 2" visibleon="Option 1|Option 2" control="text" />
<property name="Prop3" caption="Prop For Option 3" visibleon="Option 3" control="text" />
</propertygroup>
</propertygroup>
每个子属性可以指定一个属性visibleon,它可以采用一个值或一组值。如果父属性的当前值与属性visibleon 相符,则显示该属性。否则,该属性是隐藏的。
-
如果需要创建一个table定义一组属性,则可以使用 PropertyTable 类型,元素 <PropertyTable>
封装了一个table列表,其中每个子属性在table中创建一列,也可以控制table的行号。为了方便开发,ACT 提供了两种不同类型的预定义工作表:
-
Time-dependent -
Non-fixed row dimension
Time-dependent
在与时间相关的工作表中,行号使用AnalysisSettings 中定义的步骤数进行初始化。在AnalysisSettings 中添加或删除时间步时,工作表会自动更新。因此,这种类型的工作表定义了一种与时间相关的数据。
<propertytable name="TimeDep" caption="TimeDependent" display="worksheet" control="applycancel" class="Worksheet.TimeFreqTabularData.TFTabularData">
<property name="Step" caption="Step" control="integer" readonly="true" />
<property name="Time" caption="Time" control="float" readonly="true" />
<property name="Temperature" caption="Temperature" unit="Temperature" control="float"></property>
<property name="Pressure" caption="Pressure" unit="Pressure" control="float"></property>
</propertytable>
在本例中,属性display设置为worksheet,此外,属性class指定了管理工作表的IronPython类的名称。此示例使用类 TFTabularData,该类在函数库 TimeFreqTabularData.py中定义。该库随ACT一起安装,位于%ANSYSversion_DIR%\Addins\ACT\libraries\Mechanical\Worksheet。属性 Step 和 Time 集成了特定处理,因为它们会自动填充对象 AnalysisSettings 中指定的信息,这两个属性是可选的。
Non-Fixed Row Dimension Worksheets
在行数不确定的工作表中,数组默认为空。可以通过单击左上角的按钮添加新行。
<propertytable name="Worksheet" caption="Non-Fixed row count" display="worksheet" control="applycancel" class="Worksheet.PropertyGroupEditor.PGEditor">
<propertygroup name="TempOrPres" caption="TempOrPres" display="property" control="select" default="Temperature">
<attributes options="Temperature,Pressure" />
<property name="Temperature" caption="Temperature" unit="Temperature" control="float" visibleon="Temperature"></property>
<property name="Pressure" caption="Pressure" unit="Pressure" control="float" visibleon="Pressure"></property>
</propertygroup>
<property name="Scoping" caption="Scoping" control="scoping"> <attributes selection_filter="face|edge" /> </property>
<property name="FileName" caption="FileName" control="fileopen"> <attributes filters="Command files (*.bat)|*.bat|All files (*.*)|*.*" /> </property>
</propertytable>
此示例使用类PGEditor,该类在函数库PropertyGroupEditor.py中定义。该库随ACT一起安装,位于%ANSYSversion_DIR%\Addins\ACT\libraries\Mechanical\Worksheet。
4. 控件control属性的值指定“详细信息”视图中用于该属性的UI控件的类型,在ACT开发中系统提供了一些预定义模板,所有预定义的模板都可以用作控件类型直接使用。如以下模板:
scoping,component_selection,geometry_selection,fileopen,entity_selection和coordinatesystem_selection
这些模板的使用方式类似。
<propertygroup name="Group5" caption="Selection" display="caption">
<property name="Geometry" caption= "Geometry" control="scoping"> <attributes selection_filter="body" />
</property>
<property name="ComponentSelection" caption= "ComponentSelection" control="component_selection">
</property>
<property name="GeometrySelection" caption= "GeometrySelection" control="geometry_selection">
</property>
<property name="EntitySelection" caption= "EntitySelection" control="entity_selection">
</property>
<property name="CoordinateSystem" caption= "CoordinateSystem" control="coordinatesystem_selection">
</property>
</propertygroup>
以上就是本期内容,关注微信公众号,有技术问题或项目合作可以直接在微信公众号后台留言,公众号回复“DemoLoad”获取ACT代码.

工程师必备
- 项目客服
- 培训客服
- 平台客服
TOP
