定義屬性規則
屬性規則 (<attr_rules>) 是選用規則,其定義屬性何時顯示在屬性清單中。可使用屬性規則來隱藏或鎖定屬性,以及啟用屬性在插圖中的本地化。標準可以包含用來控制來源資料中的屬性是否顯示,以及將屬性鎖定在不同層級的規則。屬性規則的清單可以為空。
屬性規則在 xml 檔案中定義,新增至標準時,必須使得下列標題有效且辨識為屬性規則:
<?xml version="1.0" encoding="utf-8"?>
長度單位
必須為屬性規則檔案定義長度單位。可設定下列單位:
公釐
英吋
以下是屬性規則長度單位的範例:
<attribute_rules length_units="MILLIMETER">
type - 設定屬性類型。目前 schematics 是唯一支援的類型。
<if> - 是否存在 <if> 陳述式為選用。陳述式可以包含一個或不包含 <if>,並只包含一個 <then> 引數。若未定義 <if><then> 會對所有項目顯示。
and|or|not - 您可以將條件與布林標籤組合使用。
item - 僅套用至項目的條件。
item 引數
描述
type
項目的類型。如果 regexpr=true,您可以使用 regexpr (選用)。
name
項目的名稱。如果 regexpr=true,您可以使用 regexpr (選用)。
regexpr
在條件中使用規則運算式。
equal
引數 (type/name) 的值必須相等,條件才為 true。
caseins
陳述式為 true 時區分大小寫。
以下是套用至項目之屬性的範例:
attribute - 套用至項目屬性的條件。
attribute 引數
描述
name
屬性的名稱。如果 regexpr=true,您可以使用 regexpr (選用)。
value
屬性的值。如果 regexpr=true,您可以使用 regexpr (選用)。
regexpr
在條件中使用規則運算式。
caseins
陳述式為 true 時區分大小寫。
then - 規則必須具有 then 引數。請僅在您要套用規則時新增引數。它包含規則套用至的所有項目。
then 引數
描述
attribute
將任意數量的效果新增至屬性 (選用)。
lock
將鎖定屬性設定為 true 可將其鎖定。
visible
將屬性設定為 false 可將其隱藏。
localize
啟用屬性的本地化。
以下是 then 引數的範例:
<attr_rules>
<rule type="schematics">
<if>
<item type="co*" name="*1*" regexpr="true"/>
</if>
<then>
<attribute visible="false"/>
</then>
</rule>
<rule type="schematics">
<if>
<attribute name="*name*" regexpr="true"/>
</if>
<then>
<attribute lock="true"/>
</then>
</rule>
<rule type="schematics">
<if>
<and>
<attribute name="name"/>
<attribute value="*2*" regexpr="true"/>
</and>
</if>
<then>
<attribute localize="true" lock="false" visible="true"/>
</then>
</rule>
</attr_rules>
如需有關定義輪廓的資訊,請繼續下一節。
這是否有幫助?