質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

Blender

Blenderとは、オープンソースの3DCGソフトウェアです。フリーでありながら、3Dモデル作成、レンダリング、アニメーション、コンポジットなどのハイエンドに匹敵する高い機能を持ち、さらにゲームエンジンも搭載しています。

Q&A

1回答

806閲覧

Blender スクリプト Python

MAskai

総合スコア7

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

Blender

Blenderとは、オープンソースの3DCGソフトウェアです。フリーでありながら、3Dモデル作成、レンダリング、アニメーション、コンポジットなどのハイエンドに匹敵する高い機能を持ち、さらにゲームエンジンも搭載しています。

0グッド

0クリップ

投稿2019/09/02 10:39

Blenderにおいて、以下のスクリプトを実行したところ毎回250フレーム目で動作が止まります。解決方法はありますか?

python

1import bpy 2import math 3import fnmatch 4 5def ClearObjects(): 6 scene = bpy.context.scene 7 data = bpy.data 8 pattern = 'Copy*' 9 IcoA = [objA for objA in scene.objects if fnmatch.fnmatchcase(objA.name, pattern)] 10 IcoB = [objB for objB in data.objects if fnmatch.fnmatchcase(objB.name, pattern)] 11 IcoC = [objC for objC in data.meshes if fnmatch.fnmatchcase(objC.name, pattern)] 12 IcoD = [objD for objD in data.materials if fnmatch.fnmatchcase(objD.name, pattern)] 13 14 for item in IcoA: 15 if item.type == 'MESH': 16 bpy.context.scene.objects.unlink(item) 17 for item in IcoB: 18 if item.type == 'MESH': 19 bpy.data.objects.remove(item) 20 for item in IcoC: 21 bpy.data.meshes.remove(item) 22 for item in IcoD: 23 bpy.data.materials.remove(item) 24 25def CreateObjects(frame): 26 if (bpy.context.screen.is_animation_playing == False): 27 return 28 29 objectName='Cylinder' 30 copySrc=bpy.data.objects[objectName] 31 32 num = 12 33 r = 4 34 obj = [] 35 for i in range(num): 36 t = 2.0 * math.pi * i / num 37 x = 0.8 * r * math.cos(t) 38 y = 0.8 * r * math.sin(t) 39 40 for ob in bpy.context.scene.objects: 41 ob.select = False 42 copySrc.select = True 43 44 bpy.ops.object.duplicate(linked=True) 45 newObj=bpy.data.objects[objectName+'.001'] 46 newObj.name='Copy' 47 obj.append(newObj) 48 bpy.context.scene.objects.active = newObj 49 obj[i].location=(0,0,0) 50 51 bpy.ops.rigidbody.object_add() 52 obj[i].rigid_body.kinematic = True 53 obj[i].rigid_body.restitution = 0.6 54 obj[i].hide_render = True 55 obj[i].hide_select = True 56 obj[i].keyframe_insert( data_path='hide_render', frame=frame-1 ) 57 obj[i].keyframe_insert( data_path='hide_select', frame=frame-1 ) 58 obj[i].keyframe_insert( data_path='location', frame=frame-1 ) 59 60 obj[i].hide_render = False 61 obj[i].hide_select = False 62 obj[i].keyframe_insert( data_path='hide_render', frame=frame ) 63 obj[i].keyframe_insert( data_path='hide_select', frame=frame ) 64 65 obj[i].location = (x, y, 0.1) 66 obj[i].keyframe_insert( data_path='location', frame=frame ) 67 obj[i].rigid_body.keyframe_insert( data_path='kinematic', frame=frame ) 68 69 obj[i].location = (x*1.06, y*1.06, 0.1) 70 obj[i].keyframe_insert( data_path='location', frame=frame+1 ) 71 72 obj[i].rigid_body.kinematic = False 73 obj[i].rigid_body.keyframe_insert( data_path='kinematic', frame=frame+2 ) 74 75# every frame change, this function is called. 76def handler(scene): 77 frame = scene.frame_current 78 79 if frame == 2: 80 ClearObjects() 81 if frame % 10 == 3: 82 CreateObjects(frame) 83 if frame == scene.frame_end: 84 bpy.ops.screen.animation_cancel(restore_frame=False) 85 86def handler_render_pre(scene): 87 bpy.app.handlers.frame_change_pre.clear() 88 89ClearObjects() 90 91bpy.app.handlers.render_pre.clear() 92bpy.app.handlers.render_pre.append(handler_render_pre) 93 94bpy.app.handlers.frame_change_pre.clear() 95bpy.app.handlers.frame_change_pre.append(handler)

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

動画の開始フレームと終了フレームを指定してないので、デフォルトの終了フレーム=250が適用されているかと思います。
以下のコードを追記すると良いでしょう。

python

1bpy.context.scene.frame_start = 0 2bpy.context.scene.frame_end = 300

参考リンク

投稿2019/09/03 00:29

Ryupe

総合スコア426

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問