Qiita Conference 2025

ミノ駆動 (@MinoDriven)

プロフェッショナルとしての成長──「問題の深掘り」が導く真のスキルアップ

18
15

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

cinema4dでpythonを書いてみる。

Last updated at Posted at 2016-05-02

cinema4dでpythonを書いてみる。
pythonもよくわからなかったのでpythonの文法的なものも以下にメモした。
http://qiita.com/_nabe/items/36f6f33397e9eec4e3b9

c4dでpythonを書く場所

いくつかある。

  • スクリプトタグに書く
  • スクリプトマネージャーに書く
  • Xpressoの中に書く
  • Pythonジェネレータに書く
  • pluginとして書く

まずは練習で、スクリプトタグか、スクリプトマネージャー上で実行をよく使った。

すでに定義されている変数

ショートカット的にcinema4d側が以下の変数を定義している模様。

オブジェクトを取得し位置を変えてみる

毎フレーム、オブジェクトをランダムに動かしてみる。以下のスクリプトを、スクリプトタグに書いた。

move.py
import c4d
import random

def main():
	print "move!"
    obj = op.GetObject()
    obj[c4d.ID_BASEOBJECT_REL_POSITION,c4d.VECTOR_X] = 100 * (random.random()-0.5)
    obj[c4d.ID_BASEOBJECT_REL_POSITION,c4d.VECTOR_Y] = 100 * (random.random()-0.5)
    obj[c4d.ID_BASEOBJECT_REL_POSITION,c4d.VECTOR_Z] = 100 * (random.random()-0.5)


キャプチャはこんな感じです。
alt

c4d.ID_BASEOBJECT_REL_POSITION,c4d.VECTOR_X などのプロパティ名は、cinema4d上のスクリプトエディタにgui上のパラメータ名をドラッグすると表示される!
alt

ドキュメント

APIはここから頑張って探す。あるいはググる!
https://developers.maxon.net/docs/Cinema4DPythonSDK/html/index.html

公式っぽいサンプル

スニペット

18
15
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up

Qiita Conference 2025 will be held!: 4/23(wed) - 4/25(Fri)

Qiita Conference is the largest tech conference in Qiita!

Keynote Speaker

ymrl、Masanobu Naruse, Takeshi Kano, Junichi Ito, uhyo, Hiroshi Tokumaru, MinoDriven, Minorun, Hiroyuki Sakuraba, tenntenn, drken, konifar

View event details
18
15

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?