2つのshapeが同一か判定 (スクリプト)

2つの形状(shape)が同一のものか判定する場合は、「shape.ordinal」を使用するのが簡単です。
「shape.ordinal」は、ルートパートを0として上から順番に連番を付けたときの番号になります。


scene = xshade.scene()
shape2 = scene.get_shape_by_name("パート1")
shape = scene.active_shape()
if shape2 != None:
  print (shape2 == shape)
  print (shape2 is shape)
  print (shape2.ordinal == shape.ordinal)

“パート1″の名前の形状がブラウザで選択されているときに上記コードをスクリプト実行すると、
「shape2 == shape」はFalseを返します。
「shape2 is shape」はFalseを返します。
「shape2.ordinal == shape.ordinal」はTrueを返します。

もしくは、「shape.uuid」を比較することで同一形状かどうか判定できます。

この記事のURLとタイトルをコピーする
Translate »