#一点収束閉じ #ウィジェットに入れる場合はutfでコーディング #面をひとつ選択状態で実行すると、面を構成する頂点の平均座標にポイントAを追加し、 #ポイントAと面を構成する頂点間にエッジを張り、元の面は削除します #動作条件 #選択形状がポリゴンメッシュ #編集モードに入っている #面編集モード #選択面の数はひとつのみ dousasuru=0 #動作条件を満たしているか if xshade.scene().active_shape().type==7 and xshade.scene().is_modify_mode==True and xshade.scene().selection_mode==0: activefacelist=[] for i in range(xshade.scene().active_shape().number_of_faces): if xshade.scene().active_shape().face(i).active==True: activefacelist.append(i) if len(activefacelist)==1: dousasuru=1 if dousasuru==1: #元の形状をクリップボードにコピー xshade.scene().active_shape().copy() xshade.scene().enter_modify_mode() #平均座標値を求める vlist=xshade.scene().active_shape().face(activefacelist[0]).vertex_indices pointsuu=len(vlist) possum=[0,0,0] for i in vlist: tempos=xshade.scene().active_shape().vertex(i).position possum[0]=tempos[0]+possum[0] possum[1]=tempos[1]+possum[1] possum[2]=tempos[2]+possum[2] possum=[possum[0]/pointsuu,possum[1]/pointsuu,possum[2]/pointsuu] #頂点を追加してエッジを張る newpoint=xshade.scene().active_shape().total_number_of_control_points xshade.scene().active_shape().append_point(possum) for i in vlist: xshade.scene().active_shape().append_edge(newpoint,i) #元の面を消す xshade.scene().active_shape().face(activefacelist[0]).remove() #面の向きを統一 xshade.scene().active_shape().adjust_face_direction() #やり直すか聞く?(今回は見送り)