#表面材質を残してマージ #同一座標頂点のマージオプション追加(20100126) #shade12で処理が遅い不具合に対応(20101228) #ブラウザでポリゴンメッシュを並べ、下の方のポリゴンメッシュを選択状態でこのスクリプトを #実行すると、上の方の表面材質情報を残したままポリゴンメッシュのマージ処理が行われます。 #一度実行すると、元に戻すことはできません。 #UV情報は上の方はそのままだと思いますが、下の方のポリゴンメッシュの部分はクリアされます #オプション #ポリゴンメッシュを残す(下の方のポリゴンメッシュを残すかどうか) #編集対象外(残した場合、そのポリゴンメッシュを編集対象外にするか) #可視(残した場合、そのポリゴンメッシュを図形ウインドウで表示するか) #レンダリング対象外(残した場合、そのポリゴンメッシュをレンダリング対象外にするか) dousasuru=0 if xshade.scene().active_shape().has_sis==True: if xshade.scene().active_shape().sis.type==7: dousasuru=1 if dousasuru==1: ngon=0#5点以上で構成された面の数(後で復元する) nokosu=1#下の方のポリゴンメッシュを残すかどうか editlock=1#残した場合、下の方のポリゴンメッシュを編集対象外にする(1)かしない(0)か visible=0#残した場合、下の方のポリゴンメッシュを図形ウインドウで表示するか render=0#残した場合、下の方のポリゴンメッシュをレンダリング対象にするかどうか #ダイアログ表示 dialog=xshade.create_dialog() idx1=dialog.append_bool('ポリゴンメッシュを残す') dialog.begin_group('残すポリゴンメッシュは…') idx2=dialog.append_bool('編集対象外にする') idx3=dialog.append_bool('図形ウインドウで表示する') idx4=dialog.append_bool('レンダリング対象にする') dialog.end_group() dialog.set_value(idx1,nokosu) dialog.set_value(idx2,editlock) dialog.set_value(idx3,visible) dialog.set_value(idx4,render) kekka=dialog.ask('表面材質を残してマージ') nokosu=dialog.get_value(idx1) editlock=dialog.get_value(idx2) visible=dialog.get_value(idx3) render=dialog.get_value(idx4) if kekka==True: xshade.scene().inhibit_update() #ポリゴンメッシュの頂点座標リストとエッジの両端の頂点番号リスト、5角形以上の面の頂点タプルリストを作成 vposlist=[] v01list=[] ngonlist=[] for i in range(xshade.scene().active_shape().total_number_of_control_points): vposlist.append(xshade.scene().active_shape().vertex(i).position) for i in range(xshade.scene().active_shape().number_of_edges): v01list.append([xshade.scene().active_shape().edge(i).v0,xshade.scene().active_shape().edge(i).v1]) for i in range(xshade.scene().active_shape().number_of_faces): templist=xshade.scene().active_shape().face(i).vertex_indices if len(templist)>2: ngon+=1 ngonlist.append(templist) if nokosu==0: xshade.scene().clear() else: xshade.scene().active_shape().rendering=render temptext=xshade.scene().active_shape().name if editlock==1: xshade.scene().active_shape().modifiable=False if temptext[:1]!='~': xshade.scene().active_shape().name='~'+temptext else: xshade.scene().active_shape().modifiable=True if temptext[:1]=='~': xshade.scene().active_shape().name=temptext[1:] if visible==0: xshade.scene().hide_active() else: xshade.scene().show_active() xshade.scene().select_sister() #上のポリゴンメッシュに追加する tasu=xshade.scene().active_shape().total_number_of_control_points for i in vposlist: xshade.scene().active_shape().append_point(i) for i in v01list: # xshade.scene().active_shape().append_edge(i[0]+tasu,i[1]+tasu) xshade.scene().active_shape().make_edge(i[0]+tasu,i[1]+tasu) if ngon>0: for i in ngonlist: tempvlist=list(i) for j in range(len(tempvlist)): tempvlist[j]=tempvlist[j]+tasu temptup=tuple(tempvlist) xshade.scene().active_shape().append_face(temptup) #重複した頂点の削除 xshade.scene().active_shape().cleanup_redundant_vertices() #面の向きがおかしくならないよう面の向きを調整 xshade.scene().active_shape().adjust_face_direction() xshade.scene().allow_update()