形状のコントロールポイント数、ポリゴンメッシュの場合は頂点数を取得したい

ブラウザで形状を選択し、以下のスクリプトをスクリプトウィンドウで実行すると、
線形状や自由曲面の場合はコントロールポイント数、
ポリゴンメッシュの場合は頂点数が、メッセージウィンドウに表示されます。

shape = xshade.scene().active_shape()
print shape.total_number_of_control_points

ブラウザで複数形状が選択されている場合は、以下のスクリプトを使用します。


scene = xshade.scene()

# 階層をたどる再帰.
def getControlPointsCount (shape):
  cou = 0

  # 線形状かポリゴンメッシュの場合.
  if shape.type == 4 or shape.type == 7:
    cou += shape.total_number_of_control_points

  if shape.has_son:
    s = shape.son
    while s.has_bro:
      s = s.bro
      cou += getControlPointsCount(s)
  return cou

# shapeから階層構造をたどって出力.
aCou = 0
for shape in scene.active_shapes:
  aCou += getControlPointsCount(shape)

print 'ポイント数 : ' + str(aCou)
この記事のURLとタイトルをコピーする
Translate »