#エッジループ選択(追加型) #最後に選択したエッジから探索を開始し、エッジループを追加します #SHIFTキーを押しながらエッジを選択してからこのスクリプトを実行すると選択辺をどんどん追加していけます #追加選択したくない場合はSHIFTキーを押さないでエッジを一つだけ選択してからスクリプトを実行してください #はしっこのポイントも選べるように改良すべし #内容大幅見直し版(2010.01.29) 「まさ」さんにアドバイスいただきました。 #片面表示の際に面の向きが統一されていないような形状で使用すると落ちるバグを修正 #動作条件 #選択形状がポリゴンメッシュ #編集モードに入っている #辺編集モード #辺が一つ以上選択されている def loop_sel1(ashpe,tuikalist,imaedge,vv): startedge=imaedge while True: tempface=ashape.fcwev(imaedge,vv,False) if tempface>-1: tempedge=ashape.ecwfv(tempface,vv,False) if tempedge>-1: tempface=ashape.fcwev(tempedge,vv,False) if tempface>-1: right=ashape.ecwfv(tempface,vv,False) if right>-1: tempface=ashape.fccwev(imaedge,vv,False) if tempface>-1: tempedge=ashape.eccwfv(tempface,vv,False) if tempedge>-1: tempface=ashape.fccwev(tempedge,vv,False) if tempface>-1: left=ashape.eccwfv(tempface,vv,False) if left>-1: if left==right: if right==startedge: return True else: tuikalist.append(right) imaedge=right templist=[ashape.edge(imaedge).v0,ashape.edge(imaedge).v1] templist.remove(vv) vv=templist[0] else:return False else:return False else:return False else:return False else:return False else:return False else:return False else:return False else:return False def loop_sel2(ashape,tuikalist,imaedge,vv,type2): startedge=imaedge while True: if type2==2:tempface=ashape.fcwev(imaedge,vv,False) else:tempface=ashape.fccwev(imaedge,vv,False) if tempface>-1: if type2==2:tempedge=ashape.ecwfv(tempface,vv,False) else:tempedge=ashape.eccwfv(tempface,vv,False) if tempedge>-1: if type2==2:tempface=ashape.fcwev(tempedge,vv,False) else:tempface=ashape.fccwev(tempedge,vv,False) if tempface>-1: if type2==2:temp2=ashape.ecwfv(tempface,vv,False) else:temp2=ashape.eccwfv(tempface,vv,False) if temp2>-1: if type2==2:tempface=ashape.fcwev(temp2,vv,False) else:tempface=ashape.fccwev(temp2,vv,False) if tempface<0: if temp2==startedge:return True else: tuikalist.append(temp2) imaedge=temp2 templist=[ashape.edge(imaedge).v0,ashape.edge(imaedge).v1] templist.remove(vv) vv=templist[0] else:return False else:return False else:return False else:return False else:return False dousasuru=0 xscene=xshade.scene() ashape=xshade.scene().active_shape() if ashape.type==7 and xscene.is_modify_mode==True and xscene.selection_mode==1: edgelist=[] for i in range(ashape.number_of_edges): if ashape.edge(i).active==True: edgelist.append(i) if len(edgelist)>0:dousasuru=1 if dousasuru==1: #面の向きを統一 ashape.adjust_face_direction() #一番最後に選択に追加された辺を探す sedge=-1 aorder=-1 for i in edgelist: if ashape.edge(i).active_order>aorder: aorder=ashape.edge(i).active_order sedge=i #ポリゴンメッシュの端にある辺なのか、中にある辺なのか調べる。ついでにどっちまわりかも type=-1#隣接面が二つの場合0、一つしかない場合その1は1、 一つしかない場合その2は2 ashape.setup_winged_edge() #最後らへんでcleanし忘れないように facelist=[]#辺の隣の面リスト ev0=ashape.edge(sedge).v0 ev1=ashape.edge(sedge).v1 face1=ashape.fccwev(sedge,ev0,False) face2=ashape.fcwev(sedge,ev0,False) if face1<0 and face2<0: #隣接面無し dousasuru=0 ashape.clean_winged_edge() if face1>=0 and face2>=0:type=0 if face1>=0 and face2<0:type=1 #fccwevを使う if face1<0 and face2>=0:type=2 #fcwevを使う if dousasuru==1: xscene.inhibit_update() tuikalist=[] #typeごとに選択辺の拡張メソッドを変える if type==0: if loop_sel1(ashape,tuikalist,sedge,ev0)!=True: loop_sel1(ashape,tuikalist,sedge,ev1) if type==1: if loop_sel2(ashape,tuikalist,sedge,ev0,1)!=True: loop_sel2(ashape,tuikalist,sedge,ev1,2) if type==2: if loop_sel2(ashape,tuikalist,sedge,ev0,2)!=True: loop_sel2(ashape,tuikalist,sedge,ev1,1) ashape.clean_winged_edge() #辺を選択に追加 for i in tuikalist: ashape.edge(i).active=True xscene.allow_update()