#マルチターゲットウェルド #ラジオボタン式のダイアログを表示して、起動するツールを選択する #1マルチターゲットウェルド(開始点に総融合) #頂点編集モードで、かつ編集モードの時作動 #一番最初に選択した頂点へ、残りの選択頂点群が一気にウェルドされる #結果とともに、選択頂点の数をダイアログで表示してokボタンを押すと処理が確定、cancelボタンを押すと取り消し #選択頂点数が2個以上の場合のみ作動 #2マルチターゲットウェルド(選択順に対融合) #頂点編集モードで、かつ編集モードの時作動 #選択番号が1へ2が、3へ4が、5へ6が、7へ8が……という風に対にウェルドされていく #結果とともに、選択頂点の数をダイアログで表示してokボタンを押すと処理が確定、cancelボタンを押すと取り消し #選択頂点数が2個以上の場合のみ作動 #かつ選択頂点数が2の倍数の時のみ作動 #3マルチターゲットウェルド(座標値で対融合) #頂点編集モードで、かつ編集モードの時作動 #指定した座標値が近いもの同士がウェルドされていく #一つ目のダイアログでx座標、y座標、z座標を選択 #実行後に選択頂点の数をダイアログで表示してokボタンを押すと確定、キャンセルで取り消し #選択頂点数が2個以上の場合のみ作動 #かつ選択頂点数が2の倍数の時のみ作動 #4マルチターゲットウェルド(ダブルループウェルド) #頂点編集モードで、かつ編集モードの時作動 #選択頂点数が4個か6個のときのみ機能 def return_pointlist(pointnum): #その点と接続されている頂点の頂点番号をリストで返す(引数 頂点番号) pointlist=[] totaledgesuu=xshade.scene().active_shape().number_of_edges for i in range(totaledgesuu): if xshade.scene().active_shape().edge(i).v0==pointnum: pointlist.append(xshade.scene().active_shape().edge(i).v1) if xshade.scene().active_shape().edge(i).v1==pointnum: pointlist.append(xshade.scene().active_shape().edge(i).v0) return pointlist def return_looplist(a1,a2,a3): #辺a1a2から開始して、ループ状に頂点を追加していってリストを返す maeten=a1 imaten=a2 returnlist=[] if return_edge_number(a1,a2)!=-1: returnlist.append(a1) returnlist.append(a2) renz=1 while(renz==1): templist=return_pointlist(imaten) templist.remove(maeten) #接続頂点と構成される辺の隣接面の数を確認 kouholist=[] for i in templist: if len(return_menlist(return_edge_number(i,imaten)))<2: kouholist.append(i) if len(kouholist)>0: #a3と一緒でないか確認 if kouholist[0]==a3: returnlist.append(a3) renz=0 #すでに格納してないか確認 sumi=0 for i in returnlist: if kouholist[0]==i:sumi=1 if sumi==1:renz=0 else: returnlist.append(kouholist[0]) maeten=imaten imaten=kouholist[0] else:renz=0 return returnlist def sort_point_by_position(pointlist,ziku): #頂点の座標値が低い順にリストの頂点番号をソートして頂点リストを返す #zikuが1の時はx座標で、2の時はy座標で、3の時はz座標でソート #ソート templist=[] for i in pointlist: templist.append(i) newlist=[] while(len(newlist)0: activepointlist.append(i) pointsuu=len(activepointlist)#選択頂点数 #選択頂点数は2個以上あるか? if pointsuu<2: dousasuru=0 #選択頂点数が2個以下の時のダイアログ表示 if imamodify==1 and dousasuru==0 and pointsuu<2 and xshade.scene().selection_mode==2: dialog3=xshade.create_dialog_with_uuid('0x51900F30') idx11=dialog3.append_push_button('選択頂点数が'+str(pointsuu)+'個なので機能しません。') muridesu=dialog3.ask('マルチウェルド(開始点に総ウェルド)') #選択番号順に頂点番号をソート activepointlist2=sort_point_by_active_order(activepointlist) if dousasuru==1: #開始点と、残りの頂点群をウェルドしていく nokoripointlist=activepointlist2[1:] for i in nokoripointlist: xshade.scene().active_shape().vertex(i).position=xshade.scene().active_shape().vertex(activepointlist2[0]).position #重複した頂点の削除 xshade.scene().active_shape().cleanup_redundant_vertices() kekka=True #ダイアログを表示して、選択頂点数と結果を確認してもらう #okで確定(何もせず)cancelだと元に戻す if dousasuru==1: dialog=xshade.create_dialog_with_uuid('0x51902F00') idx1=dialog.append_push_button('選択頂点'+str(pointsuu)+'個のうち') idx2=dialog.append_push_button('最初の選択点以外を、最初の選択点へ総ウェルドしました。') idx3=dialog.append_push_button('結果を確定する場合はokを') idx4=dialog.append_push_button('取り消す場合はcancelを押してください') if imamodify==1: xshade.scene().enter_modify_mode() kekka=dialog.ask('マルチリンク(開始点に総接合)') #キャンセルなら形状を削除してクリップボードの形状を元に戻す #さらに頂点の選択状態も元に戻す? if kekka==False: idou1=0 if xshade.scene().active_shape().has_sis==True: idou1=1 xshade.scene().paste() xshade.scene().select_sister(1) xshade.scene().clear() if idou1==1: xshade.scene().select_brother() xshade.scene().enter_modify_mode() for i in activepointlist: xshade.scene().active_shape().vertex(i).active=True #選択番号が変更されているので、入れなおし for i in range(len(activepointlist2)): xshade.scene().active_shape().vertex(activepointlist2[i]).active_order=i+1 #クリップボードにコピーしたので編集モードに入っておく if imamodify==1: xshade.scene().enter_modify_mode() #開始点に総ウェルド終わり def sentakutui(): #選択順に対ウェルド imamodify=0 #今はモディファイモード? if xshade.scene().is_modify_mode==True: imamodify=1 #元の形状を念のためクリップボードにコピー xshade.scene().active_shape().copy() dousasuru=1 if xshade.scene().selection_mode!=2 or imamodify==0: dousasuru=0 #選択状態の頂点数をリストに入れる activepointlist=[] for i in range(xshade.scene().active_shape().total_number_of_control_points): if xshade.scene().active_shape().vertex(i).active_order>0: activepointlist.append(i) pointsuu=len(activepointlist)#選択頂点数 #選択頂点数は2個以上あるか? if pointsuu<2: dousasuru=0 #選択頂点数は2の倍数か? if pointsuu/2!=pointsuu/2.0: dousasuru=0 #選択頂点数が偶数でない時のダイアログ表示 if imamodify==1 and dousasuru==0 and pointsuu/2!=pointsuu/2.0 and xshade.scene().selection_mode==2: dialog3=xshade.create_dialog_with_uuid('0x51903F30') idx11=dialog3.append_push_button('選択頂点数が'+str(pointsuu)+'(奇数個)なので機能しません。') muridesu=dialog3.ask('マルチウェルド(選択順に対ウェルド)') #選択番号順に頂点番号をソート activepointlist2=sort_point_by_active_order(activepointlist) if dousasuru==1: #選択順に対ウェルドしていく for i in range(0,len(activepointlist2),2): xshade.scene().active_shape().vertex(activepointlist2[i+1]).position=xshade.scene().active_shape().vertex(activepointlist2[i]).position #重複した頂点の削除 xshade.scene().active_shape().cleanup_redundant_vertices() kekka=True #ダイアログを表示して、選択頂点数と結果を確認してもらう #okで確定(何もせず)cancelだと元に戻す if dousasuru==1: dialog=xshade.create_dialog_with_uuid('0x51904F00') idx1=dialog.append_push_button('選択頂点'+str(pointsuu)+'個を') idx2=dialog.append_push_button('選択順に対ウェルドしました。') idx3=dialog.append_push_button('結果を確定する場合はokを') idx4=dialog.append_push_button('取り消す場合はcancelを押してください') if imamodify==1: xshade.scene().enter_modify_mode() kekka=dialog.ask('マルチウェルド(選択順に対ウェルド)') #キャンセルなら形状を削除してクリップボードの形状を元に戻す #さらに頂点の選択状態も元に戻す? if kekka==False: idou1=0 if xshade.scene().active_shape().has_sis==True: idou1=1 xshade.scene().paste() xshade.scene().select_sister(1) xshade.scene().clear() if idou1==1: xshade.scene().select_brother() xshade.scene().enter_modify_mode() for i in activepointlist: xshade.scene().active_shape().vertex(i).active=True #選択番号が変更されているので、入れなおし for i in range(len(activepointlist2)): xshade.scene().active_shape().vertex(activepointlist2[i]).active_order=i+1 #クリップボードにコピーしたので編集モードに入っておく if imamodify==1: xshade.scene().enter_modify_mode() #選択順に対接合終わり def zahyousetugou(): #座標値で接合 imamodify=0 #今はモディファイモード? if xshade.scene().is_modify_mode==True: imamodify=1 #元の形状を念のためクリップボードにコピー xshade.scene().active_shape().copy() dousasuru=1 if xshade.scene().selection_mode!=2 or imamodify==0: dousasuru=0 #選択状態の頂点数をリストに入れる activepointlist=[] for i in range(xshade.scene().active_shape().total_number_of_control_points): if xshade.scene().active_shape().vertex(i).active_order>0: activepointlist.append(i) pointsuu=len(activepointlist)#選択頂点数 #選択頂点数は2個以上あるか? if pointsuu<2: dousasuru=0 #選択頂点数は2の倍数か? if pointsuu/2!=pointsuu/2.0: dousasuru=0 #選択頂点数が偶数でない時のダイアログ表示 if imamodify==1 and dousasuru==0 and pointsuu/2!=pointsuu/2.0 and xshade.scene().selection_mode==2: dialog3=xshade.create_dialog_with_uuid('0x51905F30') idx11=dialog3.append_push_button('選択頂点数が'+str(pointsuu)+'(奇数個)なので機能しません。') muridesu=dialog3.ask('マルチウェルド(座標値で対ウェルド)') #指標軸を聞くダイアログ作成 if imamodify==1 and dousasuru==1 and xshade.scene().selection_mode==2: xshade.scene().enter_modify_mode() zikudialog=xshade.create_dialog_with_uuid('0x51906F23') monn=zikudialog.append_radio_button('参考とする座標軸/x軸(横方向)/y軸(高さ方向)/z軸(奥行き方向)') zikudialog.set_value(monn,0) kekka2=zikudialog.ask('マルチリンク(座標値で対接合)') if kekka2==False: dousasuru=0 ziku2=zikudialog.get_value(monn) #選択順に戻す用 modosu=[] for i in activepointlist: modosu.append(i) modosu=sort_point_by_active_order(modosu) #座標値で頂点番号をソート activepointlist2=sort_point_by_position(activepointlist,ziku2) if dousasuru==1: #選択順に対接合していく(選択番号の低い方へ高い方がウェルドされる) for i in range(0,len(activepointlist2),2): if (xshade.scene().active_shape().vertex(activepointlist2[i]).active_order>xshade.scene().active_shape().vertex(activepointlist2[i+1]).active_order): xshade.scene().active_shape().vertex(activepointlist2[i]).position=xshade.scene().active_shape().vertex(activepointlist2[i+1]).position else: xshade.scene().active_shape().vertex(activepointlist2[i+1]).position=xshade.scene().active_shape().vertex(activepointlist2[i]).position #重複した頂点の削除 xshade.scene().active_shape().cleanup_redundant_vertices() kekka=True #ダイアログを表示して、選択頂点数と結果を確認してもらう #okで確定(何もせず)cancelだと元に戻す if dousasuru==1: dialog=xshade.create_dialog_with_uuid('0x51900F00') idx1=dialog.append_push_button('選択頂点'+str(pointsuu)+'個を') idx2=dialog.append_push_button('座標値の近いもの同士で対ウェルドしました。') idx3=dialog.append_push_button('結果を確定する場合はokを') idx4=dialog.append_push_button('取り消す場合はcancelを押してください') if imamodify==1: xshade.scene().enter_modify_mode() kekka=dialog.ask('マルチウェルド(座標値で対ウェルド)') #キャンセルなら形状を削除してクリップボードの形状を元に戻す #さらに頂点の選択状態も元に戻す? if kekka==False: idou1=0 if xshade.scene().active_shape().has_sis==True: idou1=1 xshade.scene().paste() xshade.scene().select_sister(1) xshade.scene().clear() if idou1==1: xshade.scene().select_brother() xshade.scene().enter_modify_mode() for i in activepointlist: xshade.scene().active_shape().vertex(i).active=True #選択番号が変更されているので、入れなおし for i in range(len(modosu)): xshade.scene().active_shape().vertex(modosu[i]).active_order=i+1 #クリップボードにコピーしたので編集モードに入っておく if imamodify==1: xshade.scene().enter_modify_mode() #座標値で対接合終わり def doubleloopweld(): #ダブルループウェルド #元の形状を念のためクリップボードにコピー xshade.scene().active_shape().copy() xshade.scene().enter_modify_mode() error=0 dousasuru=1 if xshade.scene().selection_mode!=2: dousasuru=0 else: activepointlist=[] for i in range(xshade.scene().active_shape().total_number_of_control_points): if xshade.scene().active_shape().vertex(i).active_order>0: activepointlist.append(i) if len(activepointlist)!=4 and len(activepointlist)!=6: dousasuru=0 error=1 if dousasuru==1: #選択番号順に頂点番号をソート activepointlist2=sort_point_by_active_order(activepointlist) if len(activepointlist)==4: alist=return_looplist(activepointlist2[0],activepointlist2[1],-1) blist=return_looplist(activepointlist2[2],activepointlist2[3],-1) if len(activepointlist)==6: alist=return_looplist(activepointlist2[0],activepointlist2[1],activepointlist2[2]) blist=return_looplist(activepointlist2[3],activepointlist2[4],activepointlist2[5]) #ウェルド if len(alist)!=0 and len(blist)!=0 and len(alist)==len(blist): for i in range(len(alist)): xshade.scene().active_shape().vertex(blist[i]).position=xshade.scene().active_shape().vertex(alist[i]).position #重なってる頂点をクリーンナップ xshade.scene().active_shape().cleanup_redundant_vertices() kekka=True #ダイアログを表示して、選択頂点数と結果を確認してもらう #okで確定(何もせず)cancelだと元に戻す dialog=xshade.create_dialog() idx2=dialog.append_push_button('処理を完了しました。') idx3=dialog.append_push_button('結果を確定する場合はokを') idx4=dialog.append_push_button('取り消す場合はcancelを押してください') # xshade.scene().enter_modify_mode() kekka=dialog.ask('マルチウェルド(ダブルループウェルド)') #キャンセルなら形状を削除してクリップボードの形状を元に戻す #さらに頂点の選択状態も元に戻す? if kekka==False: idou1=0 if xshade.scene().active_shape().has_sis==True: idou1=1 xshade.scene().paste() xshade.scene().select_sister(1) xshade.scene().clear() if idou1==1: xshade.scene().select_brother() xshade.scene().enter_modify_mode() for i in activepointlist2: xshade.scene().active_shape().vertex(i).active=True #選択番号が変更されているので、入れなおし for i in range(len(activepointlist2)): xshade.scene().active_shape().vertex(activepointlist2[i]).active_order=i+1 if error==1: #選択頂点数が4個か6個でない時のダイアログ表示 dialog3=xshade.create_dialog() idx111=dialog3.append_push_button('頂点は4個か6個選択してください') muridesu=dialog3.ask('マルチウェルド(ダブルループウェルド)') #ダブルループウェルド終わり #選択形状がポリゴンメッシュの時にのみ作動 if xshade.scene().active_shape().type==7 and xshade.scene().is_modify_mode==True and xshade.scene().selection_mode==2: #ラジオボタンを表示して使用する機能を選択 stdialog=xshade.create_dialog_with_uuid('0x51900F32') idxx=stdialog.append_radio_button('マルチウェルド/選択順に対ウェルド/開始点に総ウェルド/座標値で対ウェルド/ダブルループウェルド') stdialog.set_value(idxx,0) zikkou=stdialog.ask('マルチターゲットウェルド') sentaku=stdialog.get_value(idxx) if zikkou==True: if sentaku==0: #選択順に対ウェルド sentakutui() if sentaku==1: #開始点に総ウェルド sousetugou() if sentaku==2: #座標値で対ウェルド zahyousetugou() if sentaku==3: #ダブルループウェルド doubleloopweld()