Workbench用戶自定義控件界面顯示類型

Workbench用戶自定義控件界面顯示類型

上一期我們演示了APDL命令封裝為Mechanical用戶自定義插件,在插件中,我們只能選擇模型,設置float類型的數(shù)據(jù)。在實際使用中遇到情況會更復雜,比如通過下拉列表選擇加載形式、選擇載荷坐標系,選擇文件等情況,本期我將介紹常見的界面定義方式,實現(xiàn)以下功能。Workbench用戶自定義控件界面顯示類型的圖1

  1. 元素 <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 相符,則顯示該屬性。否則,該屬性是隱藏的。

  1. 如果需要創(chuàng)建一個table定義一組屬性,則可以使用 PropertyTable 類型,元素 <PropertyTable> 封裝了一個table列表,其中每個子屬性在table中創(chuàng)建一列,也可以控制table的行號。為了方便開發(fā),ACT 提供了兩種不同類型的預定義工作表:
  • Time-dependent
  • Non-fixed row dimension

Time-dependent

在與時間相關(guān)的工作表中,行號使用AnalysisSettings 中定義的步驟數(shù)進行初始化。在AnalysisSettings 中添加或刪除時間步時,工作表會自動更新。因此,這種類型的工作表定義了一種與時間相關(guān)的數(shù)據(jù)。

        <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,該類在函數(shù)庫 TimeFreqTabularData.py中定義。該庫隨ACT一起安裝,位于%ANSYSversion_DIR%\Addins\ACT\libraries\Mechanical\Worksheet。屬性 Step 和 Time 集成了特定處理,因為它們會自動填充對象 AnalysisSettings 中指定的信息,這兩個屬性是可選的。

Non-Fixed Row Dimension Worksheets

在行數(shù)不確定的工作表中,數(shù)組默認為空。可以通過單擊左上角的按鈕添加新行。

        <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,該類在函數(shù)庫PropertyGroupEditor.py中定義。該庫隨ACT一起安裝,位于%ANSYSversion_DIR%\Addins\ACT\libraries\Mechanical\Worksheet。
4. 控件control屬性的值指定“詳細信息”視圖中用于該屬性的UI控件的類型,在ACT開發(fā)中系統(tǒng)提供了一些預定義模板,所有預定義的模板都可以用作控件類型直接使用。如以下模板:
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>
  

以上就是本期內(nèi)容,關(guān)注微信公眾號,有技術(shù)問題或項目合作可以直接在微信公眾號后臺留言,公眾號回復“DemoLoad”獲取ACT代碼.

Workbench用戶自定義控件界面顯示類型的圖2
qrcode_for_gh_5751f214c387_344.jpg
登錄后免費查看全文
立即登錄
App下載
技術(shù)鄰APP
工程師必備
  • 項目客服
  • 培訓客服
  • 平臺客服

TOP

10
8
1