#パスジョイント複製 #パスジョイントを使ってオブジェクトをパスに沿って向きを変えながら複製するスクリプトです #「初期位置」パラメーターを追加 (2010.0606) #バグ修正(2010.0610) #動作条件 #選択形状がパスジョイント #パスジョイントの上(兄階層)にパスとなる線形状が存在する #パスジョイント内にオブジェクトが存在する #(複数のオブジェクトをまとめてコピーする場合はパートに入れてください) #パラメータ #複製回数 #ステップ #リンクを使う(チェックボックス) #初期位置・・・・デフォルトでは0の位置からスタート def count_num(): ashape3=xshade.scene().active_shape() imauuid=xshade.scene().active_shape().uuid count=1 while(1): xshade.scene().select_sister() if xshade.scene().active_shape().uuid==imauuid: break else: count+=1 imauuid=xshade.scene().active_shape().uuid ashape3.activate() return count xscene=xshade.scene() ashape=xshade.scene().active_shape() dousasuru=0 error=0 #動作条件確認 #if ashape.type==2 and ashape.part_type==7 and ashape.has_sis==True: # if ashape.sis.type==4: # if ashape.has_son==True: # if ashape.has_dad==True: # if ashape.dad.type==2: # if ashape.dad.number_of_sons==2: # dousasuru=1 # else:error=1 if ashape.type==2 and ashape.part_type==7 and ashape.has_sis==True: if ashape.sis.type==4: if ashape.has_son==True: dousasuru=1 if dousasuru==1: #ここにデフォルト値 renzoku=1 kaisuu=10 #複製回数 pstep=0.1 #ステップ linkok=0 #リンクを使うかどうか 0でOFF startp=0 #初期位置 while(renzoku==1): #ダイアログ開く dialog44=xshade.create_dialog() idx441=dialog44.append_int('複製回数') idx442=dialog44.append_float('ステップ(0より大)') idx443=dialog44.append_bool('リンクを使う') idx444=dialog44.append_float('初期位置') dialog44.set_value(idx441,kaisuu) dialog44.set_value(idx442,pstep) dialog44.set_value(idx443,linkok) dialog44.set_value(idx444,startp) kekka4=dialog44.ask('パスジョイント複製') if kekka4==False:renzoku=0 if kekka4==True: kaisuu=dialog44.get_value(idx441) if kaisuu<=0:kaisuu=1 pstep=dialog44.get_value(idx442) if pstep<0:pstep=0 linkok=dialog44.get_value(idx443) startp=dialog44.get_value(idx444) if startp<0:startp=0 #まずはパスジョイントの値を0にする ashape.path_joint.path_position=0 #パスジョイントの序数確認 # ordi=xscene.active_shape().ordinal # ordi=2 ordi=count_num() #パスジョイントの位置を初期位置に ashape.path_joint.path_position=startp #パスジョイントの下に複製物を格納するフォルダ作成 xshade.scene().create_part('複製結果') xscene.select_sister() #最初の1個目をジョイント値0の位置に複製 if linkok==0: xscene.select_child() xscene.copy() xscene.paste() if linkok==1: xscene.select_child() xscene.link_object((0.0, 0.0, 0.0),None,None,None) #複製物を先ほど作成したパートに移動 # xscene.cut() # xscene.select_parent() # xscene.select_brother() # xscene.paste() # xscene.select_parent() # xscene.select_sister() xscene.active_shape().place_parent(1) xscene.active_shape().place_brother(ordi) xscene.active_shape().place_child(1) xscene.select_parent() xscene.select_sister() #回数分繰り返す # ordi=xscene.active_shape().ordinal # ordi=2 ordi=count_num() for i in range(kaisuu): temppath=pstep*(i+1)+startp ashape.path_joint.path_position=temppath if linkok==0: xscene.select_child() xscene.copy() xscene.paste() if linkok==1: xscene.select_child() xscene.link_object((0.0, 0.0, 0.0),None,None,None) #複製物を先ほど作成したパートに移動 xscene.active_shape().place_parent(1) xscene.active_shape().place_brother(ordi) xscene.active_shape().place_child(1) xscene.active_shape().place_brother(i+1) xscene.select_parent() xscene.select_sister() #パスジョイントの値を0に戻す ashape.path_joint.path_position=0 #複製結果のパートをたたむ xscene.select_brother() xshade.scene().active_shape().undisclose_all() xscene.select_sister() #結果を確定するかどうか確認 dialog=xshade.create_dialog() dialog.append_push_button('結果を確定しますか?') kekka=dialog.ask('パスジョイント複製') if kekka==True:renzoku=0 if kekka==False: xscene.select_brother() xscene.clear() if error>0: #エラーメッセージ表示 dialogerr=xshade.create_dialog() if error==1: dialogerr.append_push_button('パートの中には') dialogerr.append_push_button('線形状と') dialogerr.append_push_button('パスジョイント') dialogerr.append_push_button('(とパスジョイントの中身)') dialogerr.append_push_button('の二つ以外は形状を') dialogerr.append_push_button('入れないでください') dialogerr.ask('エラー')