blenderモジュール
Blenderに構造をインポートする
注意
基本的な使い方
Blenderへ構造をインポート, アニメーションを作成する.
単一構造をインポートする場合
from grrmpy.blender import make_py_script,BallAndStick make_py_script("BallAndStick.py",BallAndStick(atoms))
アニメーションを作成する場合
拡張子は.zipとする. ローカルPC上でzipを展開する.展開するとpklファイルとpyファイルが入っている.これらのファイルと同じディレクトリ上でBlenderファイルを作成する.Blenderファイルを作成した後に pythonスクリプトを実行するfrom grrmpy.blender import make_py_script,Animation from ase.io import Trajectory traj = Trajectory("MD.traj") make_py_script("Animation.zip",Animation(traj))
複数のスタイルを組みわせる場合
0~8番目の原子をSpaceFilling,それ以外をStickで表現する
from grrmpy.blender import make_py_script,Stick,SpaceFilling indices1 = [0,1,2,3,4,5,6,7,8] indices2 = [i for i in range(len(atoms)) if i not in indices] # indices1以外のindex番号 make_py_script("Combine.py",[SpaceFilling(atoms,indices=indices1),Stick(atoms,indices=indices2)])
細かいパラメーターを指定する.
SpaceFillingで漫画風の描写をする
from grrmpy.blender import make_py_script,SpaceFilling make_py_script("-",SpaceFilling(atoms,cartoon={"apply":True}))
file を"-"とした場合はnotebook上にpythonスクリプトが標準出力される.
- grrmpy.blender.make_pyscript.make_py_script(file, Styles)[ソース]
Belnder用のPythonスクリプトを作成する
Parameters:
- file: str(.py or .zip)
pythonファイル名, Animationが含まれる場合はzip名 ファイル名がハイフン'-'の場合,標準出力する.(Animationがある場合は無効)
- Styles: BaseStyle object
- BallAndStick,Stick,SpaceFilling,Animationのオブジェクト複数のstyleを組み合わせる場合,リストで与える.
- class grrmpy.blender.make_pyscript.BallAndStick(atoms, indices=None, **kwargs)[ソース]
Ball and Stickのスタイル
bicolor=Trueにすると,Blender上での操作が重くなるので注意(オブジェクト数が多い)
Parameters:
- atoms: Atoms
Atomsオブジェクト
- indices: list of int
一部の原子のみを表示する場合,index番号をリストで与える
- kwargs:
- bicolor: bool
bicolorにする場合True.
- cartoon:dict
- apply: bool
- cartoonを適用する場合Ture.
- IOR: float
- フレネルのIOR(枠線の太さに相当する)
- color: tuple
- ミックスのColor2(枠線の色に相当する)1で規格化されたRGBAで指定する
- colorsdict
1で規格化したRGBA. ex) {'O':(1,0,0,1)}
- radius: float
stickの半径
- scale: flaot
- Ballの大きさ.(1の場合.SpaceFillingと同じサイズになる)元素毎に大きさを変更したい場合はscaleでなくsizesで指定する.
- sizes: dict
- 元素毎のBallの大きさ.(共有結合半径){'H':0.46, 'C':0.77}}のように指定
- stick_color: tuple
- 1で規格化されたRGBA.bicolor=Falseの時のみ有効
- subdivision_surface: dict
- applybool
- 適用する場合True.
- levelint
- viewポートでのレベル
- render_levels: int
- Renderレベル
- class grrmpy.blender.make_pyscript.Stick(atoms, indices=None, **kwargs)[ソース]
Stickのスタイル
bicolor=Trueにすると,Blender上での操作が重くなるので注意(オブジェクト数が多い)
Parameters:
- atoms: Atoms
Atomsオブジェクト
- indices: list of int
一部の原子のみを表示する場合,index番号をリストで与える
- kwargs:
- bicolor: bool
bicolorにする場合True.
- cartoon:dict
- apply: bool
- cartoonを適用する場合Ture.
- IOR: float
- フレネルのIOR(枠線の太さに相当する)
- color: tuple
- ミックスのColor2(枠線の色に相当する)1で規格化されたRGBAで指定する
- colorsdict
1で規格化したRGBA. ex) {'O':(1,0,0,1)}
- radius: float
stickの半径
- stick_color: tuple
- 1で規格化されたRGBA.bicolor=Falseの時のみ有効
- subdivision_surface: dict
- applybool
- 適用する場合True.
- levelint
- viewポートでのレベル
- render_levels: int
- Renderレベル
- class grrmpy.blender.make_pyscript.SpaceFilling(atoms, indices=None, **kwargs)[ソース]
SpaceFillingのスタイル
bicolor=Trueにすると,Blender上での操作が重くなるので注意(オブジェクト数が多い)
Parameters:
- atoms: Atoms
Atomsオブジェクト
- indices: list of int
一部の原子のみを表示する場合,index番号をリストで与える
- kwargs:
- cartoon:dict
- apply: bool
- cartoonを適用する場合Ture.
- IOR: float
- フレネルのIOR(枠線の太さに相当する)
- color: tuple
- ミックスのColor2(枠線の色に相当する)1で規格化されたRGBAで指定する
- colorsdict
1で規格化したRGBA. ex) {'O':(1,0,0,1)}
- scale: flaot
- Ballの大きさ.デフォルトは1.元素毎に大きさを変更したい場合はscaleでなくsizesで指定する.
- sizes: dict
- 元素毎のBallの大きさ.(共有結合半径){'H':0.46, 'C':0.77}}のように指定
- subdivision_surface: dict
- applybool
- 適用する場合True.
- levelint
- viewポートでのレベル
- render_levels: int
- Renderレベル
- class grrmpy.blender.make_pyscript.Animation(images, indices=None, **kwargs)[ソース]
Animationのスタイル
結合の描写が複雑なのでAnimationはSpaceFillingのみしかサポートしていないAnimationと他のスタイルを組み合わせることはできるがAnimationで指定した原子のみが動く.Parameters:
- images: Trajectory or list of Atoms
TrajectoryまたはAtomsのリスト
- indices: list of int
一部の原子のみを表示する場合,index番号をリストで与える
- kwargs:
- cartoon:dict
- apply: bool
- cartoonを適用する場合Ture.
- IOR: float
- フレネルのIOR(枠線の太さに相当する)
- color: tuple
- ミックスのColor2(枠線の色に相当する)1で規格化されたRGBAで指定する
- colorsdict
1で規格化したRGBA. ex) {'O':(1,0,0,1)}
- scale: flaot
- Ballの大きさ.デフォルトは1.元素毎に大きさを変更したい場合はscaleでなくsizesで指定する.
- sizes: dict
- 元素毎のBallの大きさ.(共有結合半径){'H':0.46, 'C':0.77}}のように指定
- start: int
始めのキーフレームを打つ位置
- step: int
何フレーム毎にキーを打つか
- subdivision_surface: dict
- applybool
- 適用する場合True.
- levelint
- viewポートでのレベル
- render_levels: int
- Renderレベル