#集合点の分解 #いくつかのスクリプトでは実行時にcleanup_redundant_vertices()というメソッドを実行して #同一座標にある頂点をマージするようにしてますが、サブディビジョンONで形状を作っている #場合、マージされると困る箇所まで強制的にマージしてしまいます。 #そのマージされたポイントを分解してくれるスクリプトです #動作条件 #選択形状がポリゴンメッシュ #編集モードに入っている #頂点編集モード #選択されている頂点が一点のみ #選択されている頂点のまわりの面が全て三角形ポリゴン #微妙に座標をずらす def return_edge_number(pointnum1,pointnum2): #頂点二つの頂点番号を与えると、その頂点で構成される辺の辺番号を返す #エラー(辺の両端のポイントでは無い)の場合は-1を返す returnnum=-1 for i in range(xshade.scene().active_shape().number_of_edges): if xshade.scene().active_shape().edge(i).v0==pointnum1 and xshade.scene().active_shape().edge(i).v1==pointnum2: returnnum=i break if xshade.scene().active_shape().edge(i).v1==pointnum1 and xshade.scene().active_shape().edge(i).v0==pointnum2: returnnum=i break return returnnum xscene=xshade.scene() ashape=xshade.scene().active_shape() dousasuru=0 if ashape.type==7 and xscene.is_modify_mode==True and xscene.selection_mode==2: activeplist=[] for i in range(ashape.total_number_of_control_points): if ashape.vertex(i).active==True: activeplist.append(i) if len(activeplist)==1:dousasuru=1 if dousasuru==1: #頂点のまわりの面が全て三角形かどうか for i in range(ashape.number_of_faces): tpvl=list(ashape.face(i).vertex_indices) for gg in tpvl: if gg==activeplist[0]: if len(tpvl)!=3:dousasuru=0 if dousasuru==1: vvlist=[]#頂点に接続されている頂点リストを頂点番号順に格納したもの for i in range(xshade.scene().active_shape().total_number_of_control_points): vvlist.append([]) for i in range(xshade.scene().active_shape().number_of_edges): vv0=xshade.scene().active_shape().edge(i).v0 vv1=xshade.scene().active_shape().edge(i).v1 tempvv=vvlist[vv0] tempvv.append(vv1) vvlist[vv0]=tempvv tempvv=vvlist[vv1] tempvv.append(vv0) vvlist[vv1]=tempvv # print activeplist # print vvlist tempvlist=vvlist[activeplist[0]] if len(tempvlist)==4: for i in tempvlist: tpos2=ashape.vertex(activeplist[0]).position tpos3=ashape.vertex(i).position if ((tpos2[0]-tpos3[0])**2)<1 and ((tpos2[1]-tpos3[1])**2)<1 and ((tpos2[2]-tpos3[2])**2)<1:dousasuru=0 if dousasuru==1: imamodify=xscene.is_modify_mode #元の形状をコピー ashape.copy() if imamodify==True:xscene.enter_modify_mode() plist=[] startp=tempvlist[0] plist.append(startp) tanten=activeplist[0] sedge=return_edge_number(startp,tanten) imaedge=sedge imap=startp ashape.adjust_face_direction() ashape.setup_winged_edge() while True: tempface=ashape.fcwev(imaedge,tanten,False) if tempface>-1: tempedge=ashape.ecwfv(tempface,tanten,False) if tempedge>-1: if tempedge==sedge:break else: if ashape.edge(tempedge).v0==tanten:imap=ashape.edge(tempedge).v1 else:imap=ashape.edge(tempedge).v0 plist.append(imap) imaedge=tempedge else:break else:break ashape.clean_winged_edge() if len(plist)