#選択状態の復帰 #あらかじめ「選択状態の記憶」スクリプトで頂点や辺、面の選択状態を記憶しておく必要があります。 #このスクリプトを実行すると兄階層の形状の選択状態を現在選択している形状へコピーします。 #動作条件 #選択形状がポリゴンメッシュ #編集モードに入っていること #現在選択している形状の真上(兄階層)に同じ頂点数、辺の数のポリゴンメッシュが置かれていること #(選択状態の記憶をやった後に頂点数や辺の数を変更しない場合は兄階層に上記条件の形状が置かれた状態になってます) #兄階層の形状の名前の頭が「~v」か「~e」か「~f」となっていること xscene=xshade.scene() ashape=xshade.scene().active_shape() dousasuru=0 if ashape.type==7 and xscene.is_modify_mode==True: if ashape.has_sis==True: tempname=ashape.sis.name if tempname[0]=='~': if tempname[1]=='v' or tempname[1]=='e' or tempname[1]=='f': if ashape.total_number_of_control_points==ashape.sis.total_number_of_control_points: if ashape.number_of_edges==ashape.sis.number_of_edges: if ashape.number_of_faces==ashape.sis.number_of_faces: dousasuru=1 if dousasuru==1: imamode=xscene.selection_mode xscene.exit_modify_mode() if tempname[1]=='v':xscene.selection_mode=2 if tempname[1]=='e':xscene.selection_mode=1 if tempname[1]=='f':xscene.selection_mode=0 #兄形状の選択状態を記憶 xscene.enter_modify_mode() xscene.select_sister(1) ashape=xshade.scene().active_shape() # ashape.modifiable=1 activelist2=[] if tempname[1]=='v': for i in range(ashape.total_number_of_control_points): if ashape.vertex(i).active==True: activelist2.append(i) if tempname[1]=='e': for i in range(ashape.number_of_edges): if ashape.edge(i).active==True: activelist2.append(i) if tempname[1]=='f': for i in range(ashape.number_of_faces): if ashape.face(i).active==True: activelist2.append(i) # ashape.modifiable=0 xscene.select_brother(1) ashape=xshade.scene().active_shape() # xscene.enter_modify_mode() #一度選択状態をクリア if tempname[1]=='v': for i in range(ashape.total_number_of_control_points): ashape.vertex(i).active=False if tempname[1]=='e': for i in range(ashape.number_of_edges): ashape.edge(i).active=False if tempname[1]=='f': for i in range(ashape.number_of_faces): ashape.face(i).active=False #選択状態変更 # print activelist2 for i in activelist2: if tempname[1]=='v':ashape.vertex(i).active=True if tempname[1]=='e':ashape.edge(i).active=True if tempname[1]=='f':ashape.face(i).active=True xscene.exit_modify_mode() xscene.enter_modify_mode()