比較キーワード
ここでは、キーワードの機能に関する簡単な説明、キーワードが影響を与える要素のタイプ(該当する場合)、有効なデータ形式(該当する場合)、およびキーワードの使用例を示します。
角度
angleキーワードは、セル、テキストノード、楕円、弧、およびテキストといった要素タイプの角度を特定します。他の要素タイプに対する角度値は0.0です。
データ形式:0.0から360.0までの実数。
例:
! ! Change the color of text ! elements rotated 90 degrees. ! if ((type == text) and (angle == 90.0)) then color = 2 endif
area_fill
area_fillキーワードは、現在の要素が塗り潰されているかどうかを確認します。
データ形式:定数(trueまたはfalse)
例:
! ! Change the fill color of all filled elements. ! Do not alter elements that are not filled. ! if (area_fill == true) then fill_color = 10 endif
cellname
cellnameキーワードは、現在の要素がセルヘッダーまたはセルの構成要素である場合、セルの名前を特定します。1つまたは複数のセル内にネスト化された構成要素の場合、cellnameキーワードは、構成要素がセルヘッダーにネスト化されていない限り、一番外側のセルの名前を特定します。この場合、cellnameキーワードはネスト化されたセルの名前となります。現在の要素がセルヘッダーまたはセルの構成要素ではない場合、cellnameの値は"NO_CELL"となります。等値または非等値の文字列比較にワイルドカードを使用できます。
データ形式:文字列
例:
! ! Change the color of all components of the cell ! named "border." ! if (cellname == "border") then color = (200,200,200) endif
characters
charactersキーワードは、現在の要素がテキスト要素である場合、要素に含まれる文字列を特定します。等値または非等値の文字列比較にワイルドカードを使用できます。
データ形式:文字列
例1:
! !Highlight any text strings that contain the string !'School' or 'Hospital'. ! if ((type == text) and (characters =='*School*')) then color = (0,0,255) else if ((type == text) and (characters =='*Hospital*')) then color = (255,0,0) endif
例2:
! !Removes the text "preliminary" if it appears in !"border" file. ! if ((lname=="border") and (characters=="preliminary")) then ignore_element=true endif
class
classキーワードは、現在の要素のクラスタイプを特定します。たとえば、現在の要素のクラスをデザインスクリプトに用いることで、現在の要素が次元の一部かパターンの一部かを特定することができます。
データ形式:0から6の整数、または次の定数のいずれかとなります。
0 primary(本図) |
1 pattern_component(パターン構成要素) |
2 construction(下書き) |
3 dimension(寸法) |
4 primary_rule(本図ルール線) |
5 linear_pattern(線パターン) |
6 construction_rule(下書きルール線) |
例:
! !Do not plot pattern and dimension class elements. if ((class == pattern_component) or (class == dimension)) then ignore_element = true endif
cls_end_width
cls_end_widthキーワードは、現在の要素に関連付けられたカスタム線種の終了幅を、デザインファイルの主単位でテストします。現在の要素にカスタム線種が関連付けられていない場合、cls_end_widthは「0.0」となります。
データ形式:実数
例:
! ! Change the color of all elements with ! a custom line style whose ending ! width is greater than 2 master design units. ! if (cls_end_width > 2.0) then color = 5 endif
cls_name
cls_nameキーワードは、現在の要素に関連付けられたカスタム線種の名前をテストします。要素にカスタム線種が関連付けられていない場合、cls_nameは"NONE"となります。
データ形式:文字列
例:
! ! Change the color of all elements using the style. ! Assign the "origin" custom line style to all ! other elements. ! if (cls_name == '{ Diamond }') then color = 2 else cls_name = "origin" endif
cls_origin_width
cls_origin_widthキーワードは、現在の要素に関連付けられたカスタム線種の開始幅を、デザインファイルの主単位でテストします。現在の要素にカスタム線種が関連付けられていない場合、cls_origin_widthは「0.0」となります。
データ形式:実数
例:
! ! Change the color of all elements with a ! custom line style whose starting ! width is greater than 2 master design units. ! if (cls_origin_width > 2.0) then color = 5 endif
cls_scale
cls_scaleキーワードは、現在の要素に関連付けられたカスタム線種に適用されている尺度をテストします。現在の要素にカスタム線種が関連付けられていない場合、cls_scaleは「1.0」となります。
データ形式:実数
例:
! ! Change the color of all elements with a ! custom line style whose scale is 2. ! if (cls_scale == 2.0) then color = 5 endif
cls_shift_distance
cls_shift_distanceキーワードは、現在の要素に関連付けられたカスタム線種に適用されているシフト距離を、デザインファイルの主単位でテストします。現在の要素にカスタム線種が関連付けられていない場合、shift_distanceは「0.0」となります。
データ形式:実数
例:
! ! Change the color of all elements with a ! custom line style whose shift ! distance is 0.5 master design units. ! if (cls_shift_distance == 0.5) then color = 5 endif
cls_shift_fraction
cls_shift_fractionキーワードは、現在の要素に関連付けられたカスタム線種に適用されているシフトの割合をテストします。現在の要素にカスタム線種が関連付けられていない場合、cls_shift_fractionは「0.0」となります。
データ形式:実数
例:
! ! Change the color of all elements with a ! custom line style whose shift ! fraction is 0.25. ! if (cls_shift_fraction == 0.25) then color = 5 endif
色
colorキーワードは、現在の要素のカラーインデックスを特定します。
データ形式:0から255までの整数。
例:
! ! Area fill shapes with a color index of 1. ! if ((color == 1) and (type == shape)) then area_fill = true endif
envr_value
envr_valueキーワードは、envr_variable代入キーワードを設定することで選択された印刷定義環境変数の値を比較するために使用されます。変数が設定されていないか有効な変数ではない場合、envr_valueは長さゼロの文字列に設定されます。
データ形式:文字列
例:
! !Get the value of the print definition environment variable !ARCHITECT. Find text element with characters !equal to "$Architect$" and change the text value !to "Designed by <name>" if ARCHITECT is equal to !"Owner1" or "Owner2." Otherwise, change the text !value to a blank string. ! envr_variable = "ARCHITECT" if((type ==text) and (characters == "$ARCHITECT$")) then if (envr_value .IN. "Owner1", "Owner2") then characters = "Designed by " + envr_value else characters = "" endif endif
envr_value_num
envr_value_numキーワードは、envr_variable代入キーワードを設定することで選択された印刷定義環境変数の値を比較するために使用されます。変数が設定されていないか有効な変数ではない場合、envr_value_numは実数のゼロに設定されます。
データ形式:実数
例:
! !Get the value of the print definition environment variable !MYCOLOR. If the value of MYCOLOR is greater than !5, set the weight to 2. ! envr_variable = "MYCOLOR" if(envr_value_num gt 5) then weight = 2 endif
file
fileキーワードは、処理されるファイルのアタッチ番号を特定します。通常、マスターファイルのアタッチ番号は0です。コマンドラインからメタファイルを生成することで、各参照ファイルのファイル名とそのアタッチ番号が印刷されます。
データ形式:整数
例:
! If the current element is in the master file ! (index of 0), change its color to 2. ! if (file == 0) then color = 2 endif
fill_color
fill_colorキーワードは、現在の要素のfill_colorインデックスを特定します。要素が塗り潰されていない場合、fill_colorは値「-1」を返します。
データ形式:-1から255までの整数。
(-1は要素への塗り潰しがないことを表す)
例:
! ! Shapes with a fill color index of 1 ! will be plotted red. ! if ((fill_color == 1) and (type == shape)) then fill_color = 'red' endif
例:
! ! Do not plot shapes that are ! not filled. ! if ((fill_color == –1) and (type == shape)) then ignore_element = true endif
first_time
first_time比較キーワードでは、デザインスクリプトのセグメントを1回実行することができます。このキーワード(フラグ)は、最初にデザインスクリプトが呼び出されたときはTRUEとなり、その後、値がFALSEに設定されます。値をリセットすることはできません。このキーワードは、ブックマークテンプレートを指定するときなどに役立ちます。このセクションの終わりにある例を参照してください。
フォント
テキストおよびテキストノードの場合、fontキーワードは現在の要素のフォント番号と等しくなります。テキストやテキストノード以外の要素のフォント番号はゼロとなります。
データ形式:0から255までの整数。
例:
! ! Do not plot text elements that use font 10. if ((type == text) and (font == 10)) then ignore_element = true endif
font_name
テキストおよびテキストノードの場合、font_nameは現在の要素のフォント名と等しくなります。テキストやテキストノード以外の要素のフォント名は"NO_FONT_NAME"となります。
データ形式:文字列
例:
! ! Change the color of all text elements ! using the "architectural" font. if ((type == text) and (font_name == 'architectural')) then color = 'gray' endif
header_level
header_level比較キーワードは、複合要素の構成要素である要素の上位レベルの親画層を返します。たとえば、デザインファイル内に単一の共有セルのインスタンスが2つあり、1つが画層2、もう1つが画層3に配置されているとします。共有セルの定義には、画層1に配置されている単一の多角形要素が含まれています。2つの図形を区別する方法は、親画層しかありません。デザインスクリプトでheader_levelキーワードを使用すれば、画層2に配置されている共有セルに標準色"red"(赤)を適用できます。
データ形式:整数
例:
! ! Change the color of a shared cell on level 2. ! if ((header_type == shared_cell) and (header_level == 2)) then color = 'red' endif
header_level_name
header_level_name比較キーワードは、複合要素の構成要素である要素の上位レベルの親画層を返します。たとえば、デザインファイル内に単一の共有セルのインスタンスが2つあり、1つが画層A、もう1つが画層Bに配置されているとします。共有セルの定義には、画層Cに配置されている単一の多角形要素が含まれています。2つの図形を区別する方法は、親画層しかありません。デザインスクリプトでheader_level_nameキーワードを使用すれば、画層Aに配置されている共有セルに標準色"red"(赤)を適用できます。
データ形式:文字列
例:
! ! Change the color of a shared cell on Level A. ! if ((header_type == shared_cell) and (header_level_name == 'Level A')) then color = 'red' endif
header_type
header_typeキーワードは、セルまたは共有セルの構成要素の一番外側の複合ヘッダーのタイプを特定します。現在の要素がセルまたは共有セルの一部ではない場合、header_typeキーワードの値は要素のタイプと同じになります。
データ形式:有効なヘッダー要素タイプに対応する整数、または次の定数のいずれかとなります。セルまたは共有セル
例1:
! ! If the current element is a component of a cell, ! change its weight to 2. ! if (header_type == cell) then weight = 2 endif
ip_scale_num
ip_scale_numキーワードは、印刷定義尺度を番号で取得します。この番号は、MS_PLT_SCALE_METHODの設定に関わらず、常に主単位または印刷単位の形で返されます。たとえば、印刷ダイアログに表示された尺度比が主単位:印刷単位である場合で、尺度が2:1に設定してある場合、単一尺度値は2.0/1.0、または2.0となります。
データ形式:実数
例:
! ! Plot line thickness based on the print definition scale. ! if (ip_scale_num ==2) then !large drawing use thick lines thickness = (weight +1) * .02 else !small drawing use thinner lines thickness = (weight +1) * .01 endif
ip_xsize_num
ip_xsize_numキーワードは、印刷定義のXサイズを数値として取得します。
データ形式:実数
例:
! ! Plot line thickness based on the print definition xsize. ! if (ip_xsize_num > 17) then !large drawing use thick lines thickness = (weight +1) * .02 else !small drawing use thinner lines thickness = (weight +1) * .01 endif
ip_ysize_num
ip_ysize_numキーワードは、印刷定義のYサイズを数値として取得します。
データ形式:実数
例:
! ! Plot line thickness based on the print definition ysize. ! if (ip_ysize_num > 17) then !large drawing use thick lines thickness = (weight +1) * .02 else !small drawing use thinner lines thickness = (weight +1) * .01 endif
画層
levelキーワードは、現在の要素の画層番号と等しくなります。
データ形式:0以上の整数
例:
! ! Set the color of the element based on its level. ! if (level == 1) then color = 1 else if (level == 2) then color = 2 endif
level_name
level_nameキーワードは、現在の要素の画層名と等しくなります。等値または非等値の文字列比較にワイルドカードを使用できます。
データ形式:文字列
例:
! ! Set the color of the element based on its level. ! if (level_name == "floor1") then color = 1 else if (level_name == "floor2") then color = 2 endif
lname
現在の要素が参照ファイルにある場合は、lnameキーワードは参照ファイルの論理名と等しくなります。現在の要素がマスターファイルにある場合は、lnameキーワードの値は空の文字列("")となります。等値または非等値の文字列比較にワイルドカードを使用できます。
データ形式:文字列
例:
! ! Change the weight of all elements in the ! reference file with the logical name of ! "border" to be a weight of 2. Elements in ! the master file and other reference ! files will not be changed. ! if (lname == 'border') then weight = 2 endif
model_format
model_formatキーワードは、DGN7、DGN8、DWG、またはDWFといったモデルフォーマットの内部の要素を操作することを可能にします。
データ形式:定数(DGN7、DGN8、DWG、またはDWF)
例:
! ! Apply a different screening percentage for ! each model format. ! if (model_format == DGN7) then screening = 20 else if (model_format == DGN8) then screening = 30 else if (model_format == DWG) then screening = 40 else if (model_format == DXF) then screening = 50 endif
nested_cellname
現在の要素がセルヘッダーまたはセルの構成要素である場合、nested_cellnameキーワードはセルの名前を特定します。1つまたは複数のセル内にネスト化された構成要素の場合、nested_cellnameキーワードは一番内側のセルの名前を特定します。現在の要素がセルヘッダーやセルの構成要素ではない場合、nested_cellnameキーワードの値は"NO_CELL"となります。等値または非等値の文字列比較にワイルドカードを使用できます。
データ形式:文字列
例:
! ! Change the weight of all components of the nested ! cell named "FRAME." ! if (nested_cellname == 'FRAME') then weight = 3 endif
プロパティ
propertiesキーワードは、プロパティ内のビットに文字要素が設定されているかどうかを特定するための2つの方法を提供します。たとえば、以下に示す2関係式は同等です。
データ形式:次の定数のいずれか
属性 |
hole(ホール) |
locked(ロック) |
modified(修正済み) |
new_element(新規要素) |
nonplanar(非平面要素) |
nonsnappable(スナップ不可能) |
screen_relative(画面相対) |
例:
! ! Do not plot any element with the screen_relative ! bit set in the properties word. ! if (properties == screen_relative) then ignore_element=true endif
size
テキスト要素の場合、sizeキーワードはテキスト文字列の高さを示します。その他の要素の場合はすべて、サイズは要素のX、Y、Z範囲の最大値となります。
データ形式:作業単位
例:
! ! Change the color of text elements whose height is ! greater than 4 subunits. ! if ((type == text) and (size > 0:4:0)) then color = 3 endif
スタイル
styleキーワードは、現在の要素の線種を示します。線種がデザインスクリプトの冒頭で設定された場合、styleは要素の元の線種ではなく、新しい線種を返します。また、要素の線種を設定するときに、名前付きの線種や移行が使用された場合、style比較キーワードはこれを反映せず、現在の線種インデックスの値を返します。
データ形式:0から7までの整数。
例:
! ! Change the color of any element not on level 1 ! that has a line style of 7. ! if ((level<>1) and (style == 7)) then color = 2 endif
tagキーワード
tagキーワードは、現在の要素にアタッチされたタグデータをチェックします。現在の要素にタグデータがアタッチされていない場合、TAG_CHARACTERキーワードは"NO_TAG_CHARACTER"を、TAG_INTEGERとTAG_REALは「NO_TAG_NUM」を返します。
次に示すのは、簡単な説明、データタイプ、およびtagキーワードの例です。
Tag_display | 特定のタイプのタグが表示されているかチェックします。 |
Tag_character | 実際のタグの値をテストします。 |
Tag_integer | 実際のタグの値をテストします。 |
Tag_real | 実際のタグの値をテストします。 |
データ形式:
例:
! ! Assuming the design file uses two tag sets, ! "Home address" and "Work address," each ! containing a character tag named "City," ! change the color of all elements whose tags ! specify a home address of "Huntsville" or a ! work address of "Madison." ! ! Start by looking for "City" tags belonging to ! the "Home address" tag set. ! tag_set = 'Home address' tag_name = 'City' if (tag_char == 'Huntsville') then color = 4 endif ! Now look for tags in the "Work address" ! tag set. Note that the tag name is still "City". tag_set = 'Work address' if (tag_char == 'Madison') then color = 4 endif
text_node_number
text_node_number比較キーワードは、テキストノード複合要素のテキストノード番号に照らしたテストに使用できます。
データ形式:整数
例1:
! ! Change the color of text associated with a specific ! text node number. ! if (text_node_number eq 46) then color = 3 endif
例2:
! ! This design script sets a plot sheet attribute ! based on the characters stored in a text node element ! in the design file. This sheet attribute can be used ! as attribute date in a digital archive. if (text_node_number eq 10) then envr_variable = "Author" envr_value = envr_value + " " + characters else if (text_node_number eq 11) then envr_variable = "Title" envr_value = envr_value + " " + characters endif
タイプ
typeキーワードは、現在の要素の要素タイプを特定します。
データ形式:有効な要素タイプに対応する整数、または次の定数のいずれかとなります。
arc(弧、タイプ16) | line_string(連続線分、タイプ4) |
assoc_dim(関連寸法、タイプ33) | mesh(メッシュ、タイプ105) |
bspline_curve(B-スプライン曲線、タイプ27) | multiline(複線、タイプ36) |
bsplne_surface(B-スプライン曲面、タイプ24) | shape(図形、タイプ6) |
cell(セル、タイプ2) | shared_cell(共有セル、タイプ35) |
complex_shape(複合図形、タイプ14) | solid(ソリッド、タイプ19) |
connected_string(接続線分、タイプ12) | surface(サーフェス、タイプ18) |
curve(曲線、タイプ11) | text(テキスト、タイプ17) |
ellipse(楕円、タイプ15) | text_node(テキストノード、タイプ7) |
line(線分、タイプ3) |
例:
! ! Change the color of lines, linestrings, and curves ! on level 1 ! if ((type in 3,4,11) and (level == 1)) then color = 1 endif
weight
weightキーワードは、現在の要素の線幅の値を示します。
データ形式:0から31までの整数。
例:
! ! Set color of element based upon its weight ! units = inches if (weight == 0) then color = 1 else if (weight == 1) then color = 2 else if (weight == 2) then color = 3 else if (weight == 3) then color = 4 else if (weight == 4) then color = 5 else if (weight == 5) then color = 6 endif
width
widthキーワードは、2次元線分、連続線分、楕円、弧、接続線分のみに有効です。その他すべての要素と3次元要素の場合、幅値は0となります。幅値は要素のZ最小範囲フィールドから取得され、線幅値とは対照的に、要素の線の幅を作業単位で特定します。
データ形式:作業単位
例:
! ! Change the color of lines, linestrings, connected ! strings, arcs, and ellipses based on their width. ! units = inches if (type .in. 3,4,12,15,16) then if (width == 0:0:050) then color = 1 else if (width == 0:0:100) then color = 2 else if (width == 0:0:150) then color = (30,50,100) else if (width == 0:0:200) then color = (100,0,0) else if (width > 0:0:300) then color = (0,0,0) endif endif