これはなに?
Cinema4DのPython環境やc4dモジュールについて
だらだら潜ってみました
以前イベントで頒布したC4D Pythonコピー本の延長でもあり、
気持ち的にはこちらの続きでもあり…?
Cinema4D、OSXでのコマンドラインオプションなど
http://qiita.com/it_ks/items/5c052366fb8d1c9952b0
承前
ここではモジュール名とややしくなるので、
「c4d」といえばPythonモジュールの方。アプリケーションの方はCinema4Dと略さず書きます。たいだいは。
環境
OSX 10.10.5、Cinema4D R14。
print c4d.GetC4DVersion()
14042
五桁のintで返ってきました。aboutダイアログで見ると、14と042で分かれてますけど。
ちなみにAPIのバージョンは(▼)
print c4d.GetAPIVersion()
(1, 1, 2406)
# あこっちはこういう感じか
Cinema4D R14のPython環境は2.6.4。
print sys.version_info
(2, 6, 4, 'final', 0)
OSのバージョンも一応Python経由で取ってみる。
import platform
print platform.mac_ver()
('10.10.5', ('', '', ''), 'i386')
Version Type
Cinema4Dには全部入りのStudio以下BroadcastやPrimeといったグレード違いが存在します。
API的にはそれらの分類を「バージョンタイプ」と呼ぶようです。
print c4d.GeGetVersionType()
4
当方が使っているCinema4Dのバージョンタイプは「4」とのこと。4,とは…?
こちらによると、
https://developers.maxon.net/docs/Cinema4DPythonSDK/html/modules/c4d/index.html#c4d.GeGetVersionType
0から数えて4は「Cinema 4D Broadcast.」。正解!
print c4d.VERSIONTYPE_BROADCAST
4
とりあえずdir()
なかに何も入れずにdir()。平置きになってる道具を確認。
import c4d
from c4d import gui
# Welcome to the world of Python
print dir()
['__builtins__', '__file__', '__name__', '__package__', 'c4d', 'doc', 'gui', 'op']
- c4d
- doc
- op
は、なにもしなくても置かれるもの、基本装備、という感じです。
c4d
print type( c4d )
<type 'module'>
help( c4d )
Help on module c4d:
NAME
c4d - Common module for the most required classes and functions.
FILE
(built-in)
SUBMODULES
bitmaps
documents
gui
internals
modules
plugins
storage
threading
utils
CLASSES
__builtin__.object
BaseContainer
BaseSelect
BaseTime
C4DAtom
GeListNode
BaseList2D
BaseMaterial
BaseObject
CameraObject
PointObject
LineObject
PolygonObject
SplineObject
BaseShader
BaseTag
SelectionTag
TextureTag
VariableTag
NormalTag
PointTag
PolygonTag
SegmentTag
TangentTag
UVWTag
BaseView
BaseDraw
CCurve
CTrack
CKey
CPolygon
CustomDataType
DateTimeData
FontData
Gradient
InExcludeData
LayerSet
MatAssignData
PLAData
PriorityData
SplineData
UnitScaleData
DescID
DescLevel
HandleInfo
Matrix
Vector
class BaseContainer(__builtin__.object)
| A container for individual values.
|
| Methods defined here:
|
| CopyTo(...)
| Copy to another BaseContainer.
|
(後略)
dir( c4d )
すごい量が返ってきて、Cinema4Dのコンソールには全ては表示できず
項目数だけ見てみます。
print len(dir(c4d))
17828
強い
doc
print type( doc )
<type 'c4d.documents.BaseDocument'>
c4d.documentsの中に入ってる「BaseDocument」が正体なようです。
ほかの仲間は……
print dir( c4d.documents )
['AddMarker', 'BaseDocument', 'BatchRender', 'CloseAllDocuments', 'GetActiveDocument', 'GetBatchRender', 'GetFirstDocument', 'GetFirstMarker', 'InsertBaseDocument', 'InteractiveModeling_Restart', 'IsolateObjects', 'KillDocument', 'LayerObject', 'LoadDocument', 'LoadFile', 'MergeDocument', 'RenderData', 'RenderDocument', 'RunAnimation', 'SaveDocument', 'SetActiveDocument', 'SetDocumentTime', 'StopExternalRenderer', '__doc__', '__name__', '__package__']
Cinema4Dが扱うファイル(シーンファイル)をどうこうするためのモジュールっぽいですね、c4d.documents。
help( doc )
Help on BaseDocument object:
class BaseDocument(c4d.BaseList2D)
| Represents a document.
|
| Method resolution order:
| BaseDocument
| c4d.BaseList2D
| c4d.GeListNode
| c4d.C4DAtom
| __builtin__.object
|
| Methods defined here:
|
| AddUndo(...)
| Perform a redo on this document (undo the last undo).
|
| AnimateObject(...)
| Animate a node in this document.
|
| DoRedo(...)
| Perform a redo on this document (undo the last undo).
|
| DoUndo(...)
| Perform an undo operation.
|
| EndUndo(...)
| End the building of multiple undo actions into a single user undo.
(後略)
dir( doc )
このひとは最後まで表示できました。
print dir( doc )
['AddUndo', 'AddUserData', 'AnimateObject', 'ChangeNBit', 'CheckType', 'ClearKeyframeSelection', 'CopyTo', 'DelBit', 'DoRedo', 'DoUndo', 'Edit', 'EndUndo', 'ExecutePasses', 'FindCTrack', 'FindKeyframeSelection', 'FindSceneHook', 'FindUndoPtr', 'Flush', 'FlushUndoBuffer', 'ForceCreateBaseDraw', 'GetAction', 'GetActiveBaseDraw', 'GetActiveMaterial', 'GetActiveMaterials', 'GetActiveObject', 'GetActiveObjects', 'GetActiveObjectsFilter', 'GetActiveRenderData', 'GetActiveTag', 'GetActiveTags', 'GetActiveToolData
', 'GetAllBits', 'GetAllTextures', 'GetBaseDraw', 'GetBaseDrawCount', 'GetBit', 'GetBubbleHelp', 'GetCTrackRoot', 'GetCTracks', 'GetChanged', 'GetChildren', 'GetClassification', 'GetClone', 'GetData', 'GetDataInstance', 'GetDirty', 'GetDocument', 'GetDocumentName', 'GetDocumentPath', 'GetDown', 'GetDownLast', 'GetDrawTime', 'GetFirstCTrack', 'GetFirstMaterial', 'GetFirstObject', 'GetFirstRenderData', 'GetFirstShader', 'GetFps', 'GetHelperAxis', 'GetHighest', 'GetIcon', 'GetInfo', 'GetLOD', 'GetLayerData',
'GetLayerObject', 'GetLayerObjectRoot', 'GetListHead', 'GetLoopMaxTime', 'GetLoopMinTime', 'GetMain', 'GetMaterials', 'GetMaxTime', 'GetMinTime', 'GetMode', 'GetNBit', 'GetNLARoot', 'GetName', 'GetNext', 'GetNodeData', 'GetObjects', 'GetOrderedActiveObjects', 'GetParticleSystem', 'GetPred', 'GetRenderBaseDraw', 'GetRenderLod', 'GetSelection', 'GetSettingsInstance', 'GetSplinePlane', 'GetTime', 'GetType', 'GetTypeName', 'GetUndoPtr', 'GetUp', 'GetUserDataContainer', 'InsertAfter', 'InsertBefore', 'InsertMat
erial', 'InsertObject', 'InsertRenderData', 'InsertRenderDataLast', 'InsertShader', 'InsertTrackSorted', 'InsertUnder', 'InsertUnderLast', 'IsAlive', 'IsAxisEnabled', 'IsDocumentRelated', 'IsEditMode', 'IsInstanceOf', 'KeyframeSelectionContent', 'Message', 'MultiMessage', 'Polygonize', 'Read', 'ReadObject', 'Remove', 'RemoveUserData', 'Scale', 'SearchMaterial', 'SearchMaterialInc', 'SearchObject', 'SearchObjectInc', 'SendInfo', 'SetAction', 'SetActiveMaterial', 'SetActiveObject', 'SetActiveRenderData', 'Se
tActiveTag', 'SetAllBits', 'SetBit', 'SetChanged', 'SetData', 'SetDirty', 'SetDocumentName', 'SetDocumentPath', 'SetFps', 'SetKeyframeSelection', 'SetLOD', 'SetLayerData', 'SetLayerObject', 'SetLoopMaxTime', 'SetLoopMinTime', 'SetMaxTime', 'SetMinTime', 'SetMode', 'SetName', 'SetRenderLod', 'SetRewind', 'SetSelection', 'SetTime', 'SetUserDataContainer', 'StartUndo', 'ToggleBit', 'TransferGoal', 'Write', 'WriteObject', '__call__', '__class__', '__delattr__', '__delitem__', '__doc__', '__eq__', '__format__',
'__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__init__', '__le__', '__len__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setitem__', '__sizeof__', '__str__', '__subclasshook__']
一応項目数。
print len(dir( doc ))
182
ところで全部頭文字が大文字ですが、これは全部クラスと思っていいのかな?
for i in dir(doc):
print i,':',eval('type(doc.'+i+')')
AddUndo : <type 'builtin_function_or_method'>
AddUserData : <type 'builtin_function_or_method'>
AnimateObject : <type 'builtin_function_or_method'>
ChangeNBit : <type 'builtin_function_or_method'>
CheckType : <type 'builtin_function_or_method'>
ClearKeyframeSelection : <type 'builtin_function_or_method'>
CopyTo : <type 'builtin_function_or_method'>
DelBit : <type 'builtin_function_or_method'>
DoRedo : <type 'builtin_function_or_method'>
DoUndo : <type 'builtin_function_or_method'>
Edit : <type 'builtin_function_or_method'>
EndUndo : <type 'builtin_function_or_method'>
ExecutePasses : <type 'builtin_function_or_method'>
FindCTrack : <type 'builtin_function_or_method'>
FindKeyframeSelection : <type 'builtin_function_or_method'>
FindSceneHook : <type 'builtin_function_or_method'>
FindUndoPtr : <type 'builtin_function_or_method'>
Flush : <type 'builtin_function_or_method'>
FlushUndoBuffer : <type 'builtin_function_or_method'>
ForceCreateBaseDraw : <type 'builtin_function_or_method'>
GetAction : <type 'builtin_function_or_method'>
GetActiveBaseDraw : <type 'builtin_function_or_method'>
GetActiveMaterial : <type 'builtin_function_or_method'>
GetActiveMaterials : <type 'builtin_function_or_method'>
GetActiveObject : <type 'builtin_function_or_method'>
GetActiveObjects : <type 'builtin_function_or_method'>
GetActiveObjectsFilter : <type 'builtin_function_or_method'>
GetActiveRenderData : <type 'builtin_function_or_method'>
GetActiveTag : <type 'builtin_function_or_method'>
GetActiveTags : <type 'builtin_function_or_method'>
GetActiveToolData : <type 'builtin_function_or_method'>
GetAllBits : <type 'builtin_function_or_method'>
GetAllTextures : <type 'builtin_function_or_method'>
GetBaseDraw : <type 'builtin_function_or_method'>
GetBaseDrawCount : <type 'builtin_function_or_method'>
GetBit : <type 'builtin_function_or_method'>
GetBubbleHelp : <type 'builtin_function_or_method'>
GetCTrackRoot : <type 'builtin_function_or_method'>
GetCTracks : <type 'builtin_function_or_method'>
GetChanged : <type 'builtin_function_or_method'>
GetChildren : <type 'builtin_function_or_method'>
GetClassification : <type 'builtin_function_or_method'>
GetClone : <type 'builtin_function_or_method'>
GetData : <type 'builtin_function_or_method'>
GetDataInstance : <type 'builtin_function_or_method'>
GetDirty : <type 'builtin_function_or_method'>
GetDocument : <type 'builtin_function_or_method'>
GetDocumentName : <type 'builtin_function_or_method'>
GetDocumentPath : <type 'builtin_function_or_method'>
GetDown : <type 'builtin_function_or_method'>
GetDownLast : <type 'builtin_function_or_method'>
GetDrawTime : <type 'builtin_function_or_method'>
GetFirstCTrack : <type 'builtin_function_or_method'>
GetFirstMaterial : <type 'builtin_function_or_method'>
GetFirstObject : <type 'builtin_function_or_method'>
GetFirstRenderData : <type 'builtin_function_or_method'>
GetFirstShader : <type 'builtin_function_or_method'>
GetFps : <type 'builtin_function_or_method'>
GetHelperAxis : <type 'builtin_function_or_method'>
GetHighest : <type 'builtin_function_or_method'>
GetIcon : <type 'builtin_function_or_method'>
GetInfo : <type 'builtin_function_or_method'>
GetLOD : <type 'builtin_function_or_method'>
GetLayerData : <type 'builtin_function_or_method'>
GetLayerObject : <type 'builtin_function_or_method'>
GetLayerObjectRoot : <type 'builtin_function_or_method'>
GetListHead : <type 'builtin_function_or_method'>
GetLoopMaxTime : <type 'builtin_function_or_method'>
GetLoopMinTime : <type 'builtin_function_or_method'>
GetMain : <type 'builtin_function_or_method'>
GetMaterials : <type 'builtin_function_or_method'>
GetMaxTime : <type 'builtin_function_or_method'>
GetMinTime : <type 'builtin_function_or_method'>
GetMode : <type 'builtin_function_or_method'>
GetNBit : <type 'builtin_function_or_method'>
GetNLARoot : <type 'builtin_function_or_method'>
GetName : <type 'builtin_function_or_method'>
GetNext : <type 'builtin_function_or_method'>
GetNodeData : <type 'builtin_function_or_method'>
GetObjects : <type 'builtin_function_or_method'>
GetOrderedActiveObjects : <type 'builtin_function_or_method'>
GetParticleSystem : <type 'builtin_function_or_method'>
GetPred : <type 'builtin_function_or_method'>
GetRenderBaseDraw : <type 'builtin_function_or_method'>
GetRenderLod : <type 'builtin_function_or_method'>
GetSelection : <type 'builtin_function_or_method'>
GetSettingsInstance : <type 'builtin_function_or_method'>
GetSplinePlane : <type 'builtin_function_or_method'>
GetTime : <type 'builtin_function_or_method'>
GetType : <type 'builtin_function_or_method'>
GetTypeName : <type 'builtin_function_or_method'>
GetUndoPtr : <type 'builtin_function_or_method'>
GetUp : <type 'builtin_function_or_method'>
GetUserDataContainer : <type 'builtin_function_or_method'>
InsertAfter : <type 'builtin_function_or_method'>
InsertBefore : <type 'builtin_function_or_method'>
InsertMaterial : <type 'builtin_function_or_method'>
InsertObject : <type 'builtin_function_or_method'>
InsertRenderData : <type 'builtin_function_or_method'>
InsertRenderDataLast : <type 'builtin_function_or_method'>
InsertShader : <type 'builtin_function_or_method'>
InsertTrackSorted : <type 'builtin_function_or_method'>
InsertUnder : <type 'builtin_function_or_method'>
InsertUnderLast : <type 'builtin_function_or_method'>
IsAlive : <type 'builtin_function_or_method'>
IsAxisEnabled : <type 'builtin_function_or_method'>
IsDocumentRelated : <type 'builtin_function_or_method'>
IsEditMode : <type 'builtin_function_or_method'>
IsInstanceOf : <type 'builtin_function_or_method'>
KeyframeSelectionContent : <type 'builtin_function_or_method'>
Message : <type 'builtin_function_or_method'>
MultiMessage : <type 'builtin_function_or_method'>
Polygonize : <type 'builtin_function_or_method'>
Read : <type 'builtin_function_or_method'>
ReadObject : <type 'builtin_function_or_method'>
Remove : <type 'builtin_function_or_method'>
RemoveUserData : <type 'builtin_function_or_method'>
Scale : <type 'builtin_function_or_method'>
SearchMaterial : <type 'builtin_function_or_method'>
SearchMaterialInc : <type 'builtin_function_or_method'>
SearchObject : <type 'builtin_function_or_method'>
SearchObjectInc : <type 'builtin_function_or_method'>
SendInfo : <type 'builtin_function_or_method'>
SetAction : <type 'builtin_function_or_method'>
SetActiveMaterial : <type 'builtin_function_or_method'>
SetActiveObject : <type 'builtin_function_or_method'>
SetActiveRenderData : <type 'builtin_function_or_method'>
SetActiveTag : <type 'builtin_function_or_method'>
SetAllBits : <type 'builtin_function_or_method'>
SetBit : <type 'builtin_function_or_method'>
SetChanged : <type 'builtin_function_or_method'>
SetData : <type 'builtin_function_or_method'>
SetDirty : <type 'builtin_function_or_method'>
SetDocumentName : <type 'builtin_function_or_method'>
SetDocumentPath : <type 'builtin_function_or_method'>
SetFps : <type 'builtin_function_or_method'>
SetKeyframeSelection : <type 'builtin_function_or_method'>
SetLOD : <type 'builtin_function_or_method'>
SetLayerData : <type 'builtin_function_or_method'>
SetLayerObject : <type 'builtin_function_or_method'>
SetLoopMaxTime : <type 'builtin_function_or_method'>
SetLoopMinTime : <type 'builtin_function_or_method'>
SetMaxTime : <type 'builtin_function_or_method'>
SetMinTime : <type 'builtin_function_or_method'>
SetMode : <type 'builtin_function_or_method'>
SetName : <type 'builtin_function_or_method'>
SetRenderLod : <type 'builtin_function_or_method'>
SetRewind : <type 'builtin_function_or_method'>
SetSelection : <type 'builtin_function_or_method'>
SetTime : <type 'builtin_function_or_method'>
SetUserDataContainer : <type 'builtin_function_or_method'>
StartUndo : <type 'builtin_function_or_method'>
ToggleBit : <type 'builtin_function_or_method'>
TransferGoal : <type 'builtin_function_or_method'>
Write : <type 'builtin_function_or_method'>
WriteObject : <type 'builtin_function_or_method'>
__call__ : <type 'method-wrapper'>
__class__ : <type 'type'>
__delattr__ : <type 'method-wrapper'>
__delitem__ : <type 'method-wrapper'>
__doc__ : <type 'str'>
__eq__ : <type 'method-wrapper'>
__format__ : <type 'builtin_function_or_method'>
__ge__ : <type 'method-wrapper'>
__getattribute__ : <type 'method-wrapper'>
__getitem__ : <type 'method-wrapper'>
__gt__ : <type 'method-wrapper'>
__hash__ : <type 'method-wrapper'>
__init__ : <type 'method-wrapper'>
__le__ : <type 'method-wrapper'>
__len__ : <type 'method-wrapper'>
__lt__ : <type 'method-wrapper'>
__ne__ : <type 'method-wrapper'>
__new__ : <type 'builtin_function_or_method'>
__reduce__ : <type 'builtin_function_or_method'>
__reduce_ex__ : <type 'builtin_function_or_method'>
__repr__ : <type 'method-wrapper'>
__setattr__ : <type 'method-wrapper'>
__setitem__ : <type 'method-wrapper'>
__sizeof__ : <type 'builtin_function_or_method'>
__str__ : <type 'method-wrapper'>
__subclasshook__ : <type 'builtin_function_or_method'>
全部関数。そんな日もある。
op
print type(op)
<type 'NoneType'>
ナゾい。
help( op )
Welcome to Python 2.6! This is the online help utility.
If this is your first time using Python, you should definitely check out
the tutorial on the Internet at http://docs.python.org/tutorial/.
Enter the name of any module, keyword, or topic to get help on writing
Python programs and using Python modules. To quit this help utility and
return to the interpreter, just type "quit".
To get a list of available modules, keywords, or topics, type "modules",
"keywords", or "topics". Each module also comes with a one-line summary
of what it does; to list the modules whose summaries contain a given word
such as "spam", type "modules spam".
help>
You are now leaving help and returning to the Python interpreter.
If you want to ask for help on a particular object directly from the
interpreter, you can type "help(object)". Executing "help('string')"
has the same effect as typing a particular string at the help> prompt.
???
普通のhelp(None)
と違う……
# ターミナル上で help(None)
>>> help(None)
Help on NoneType object:
class NoneType(object)
| Methods defined here:
|
| __hash__(...)
| x.__hash__() <==> hash(x)
|
| __repr__(...)
| x.__repr__() <==> repr(x)
(END)
なんかCinema4D内Pythonが一回落ちて再起動してるっぽい。なにこれコワイw
BaseObject
実はopは、なにかオブジェクトを選択してると中身が入る。
c4d.CallCommand(5159) # 立方体
print type(op)
<type 'c4d.BaseObject'>
c4d.BaseObjectのインスタンスであるご様子。
あらためてhelp( op )
help(op)
Help on BaseObject object:
class BaseObject(BaseList2D)
| Object base class.
|
| Method resolution order:
| BaseObject
| BaseList2D
| GeListNode
| C4DAtom
| __builtin__.object
|
| Methods defined here:
|
| AddDependence(...)
| Add a child object to the dependence list.
|
| CheckCache(...)
| Check if cache is built.
|
| CompareDependenceList(...)
| Compares if anything in the dependence list has changed.
|
| CopyMatrixTo(...)
| Copy the matrix of the object to another.
|
| CopyTagsTo(...)
| Copy the tags of the object to another.
(後略)
dir( op )
このひとも、dirしてみたら中身全部頭文字大文字、全部関数、でした。
print len( dir(op) )
168
sys
import sys
print sys.modules.keys()
['MacOS', 'subprocess', 'gc', 'c4d.modules', 'c4d.modules.particles', 'encodings.encodings', 'struct', 'c4d.modules.character.builder', 'c4dPyHelper', 'imp', 'c4d.utils', 'collections', 'zipimport', 'string', 'repr', 'signal', 'c4d.internals', 'pydoc', 'token', 'shlex', 'macostools', 'dis', 'cStringIO', 'encodings', 'abc', 're', 'UserDict', 'fcntl', 'c4d.utils.noise', 'inspect', 'exceptions', 'Carbon.Res', 'codecs', 'pkgutil', 'traceback', '_Res', 'itertools', 'opcode', 'os', 'marshal', '_collections', '_s
re', '__builtin__', 'operator', 'c4d.storage', 'select', 'c4d.modules.character', 'posixpath', 'errno', 'binascii', 'sre_constants', 'c4d', 'os.path', 'c4d.gui', 'c4d.modules.snap', 'Carbon', 'c4d.modules.onlinehelp', '_warnings', 'Carbon.Files', 'encodings.__builtin__', '_codecs', 'tokenize', 'c4d.plugins', 'webbrowser', 'Carbon.File', '_struct', 'keyword', '_File', 'posix', 'encodings.aliases', 'Carbon._Res', 'c4d.modules.hair', 'sre_parse', 'pickle', 'copy_reg', 'sre_compile', 'site', '__main__', 'c4d.m
odules.bodypaint', 'ic', 'strop', 'c4d.threading', 'encodings.codecs', 'Carbon._File', '_abcoll', 'c4d.documents', 'c4d.bitmaps', 'c4d.modules.thinkingparticles', 'genericpath', 'stat', 'warnings', 'encodings.ascii', 'time', 'sys', 'types', 'icglue', 'c4d.modules.render', 'c4d.modules.graphview', 'c4d.modules.mograph', 'linecache', 'Carbon.warnings']
結構c4d以下のをあれこれ読んでるんですね。
print sys.getdefaultencoding()
ascii
エンコード、asciiすか。
# ファイルシステムのも見てみる。
print sys.getfilesystemencoding()
utf-8
>>> sys.getfilesystemencoding()
'utf-8'
システムエンコードとは変えてくる姿勢。
print sys.argv
['']
print sys.stdin
print sys.stdout
print sys.stderr
<__main__.StdCatcher instance at 0x11b7191b8>
<__main__.StdCatcher instance at 0x11b7191b8>
<__main__.StdErrCatcher instance at 0x11b719170>
StdCatcher。。。
help( sys.stdin )
Help on instance of StdCatcher in module __main__:
class StdCatcher
| Methods defined here:
|
| flush(self)
|
| readline(self)
|
| write(self, st)
print sys.exec_prefix
/Applications/MAXON/CINEMA 4D R14/resource/modules/python/res/Python.osx.framework
print sys.prefix
/Applications/MAXON/CINEMA 4D R14/resource/modules/python/res/Python.osx.framework
print sys.executable
/Applications/MAXON/CINEMA 4D R14/CINEMA 4D.app/Contents/MacOS/CINEMA 4D
print sys.flags
sys.flags(debug=0, py3k_warning=0, division_warning=0, division_new=0, inspect=0, interactive=0, optimize=0, dont_write_bytecode=1, no_user_site=0, no_site=0, ignore_environment=0, tabcheck=0, verbose=0, unicode=0, bytes_warning=0)
dont_write_bytecode=1
とのことで、
.pycとか.pyoを生成しません。
c4d内「Command」ファミリー
Command Handlerたち。
# 例えば 5159というIDについて
c4d.CallCommand(5159) # 立方体
print c4d.GetCommandName(5159)
立方体
print c4d.GetCommandHelp(5159)
立方体 オブジェクトを追加
help(c4d.CallCommand)
Help on built-in function CallCommand in module c4d:
CallCommand(...)
Call Command
……helpコマンドに何かを期待するのは間違ってるのかなー?
そのIDなんのコマンドなの
forで回して片っ端から問い合わせてみる。
ただし、"ID"で始まるもののみ。
for i in dir(c4d):
if i.startswith('ID'):
tmpID = c4d.__dict__[i]
if c4d.GetCommandName(tmpID):
print i,tmpID,c4d.GetCommandName(tmpID)
IDM_CM_CLOSEWINDOW 12097 閉じる
IDM_COPY 12107 コピー
IDM_CUT 12106 カット
IDM_DELETE 12109 消去
IDM_INVERSION 12374 全て反転
IDM_KEY_LAST 12415 前のキーへ移動
IDM_KEY_NEXT 12416 次のキーへ移動
IDM_PASTE 12108 ペースト
IDM_REDO 12297 再実行
IDM_SELECTALL 12112 全て選択
IDM_SELECTNONE 12113 全て選択解除
IDM_UNDO 12105 取消し
ID_BASECURVE 1015549 IGESカーブ
ID_BASEGROUP 1015545 IGESグループ
ID_BASESURFACE 1015548 IGESサーフェイス
ID_CAMERA_LOCK_PIVOT 440000104 カメラピボットをロック
ID_CAMERA_MAGNIFY 1016008 フィルムのズーム
ID_CAMERA_MOVE 1016007 フィルムを移動
ID_CAMERA_SET_PIVOT 1021420 カメラピボットを設定
ID_CAMERA_ZOOM 1016009 フィルムの拡大縮小
ID_CAMERA_ZOOM_IN 1016010 ズームイン
ID_CAMERA_ZOOM_OUT 1016011 ズームアウト
ID_CA_CONSTRAINT_TAG_CLAMP_TARGET_COUNT 50000 レンダリング設定
ID_CA_CONSTRAINT_TAG_MIRROR_TARGET_COUNT 70000 フィルタを表示
ID_CA_CONSTRAINT_TAG_SPRING_TARGET_COUNT 60000 エクスポートフィルタ
ID_CA_PAINT_TOOL_DISPLAY_COLOR 12002 停止
ID_CONVERT_SELECTION_TOOL 1011181 選択範囲を変換
ID_LASTTOOL_END 1021392 -
ID_LASTTOOL_START 1021385 移動
ID_MAPPEDCURVE 1015547 IGESマップドカーブ
ID_MEASURE_TOOL 1011182 測定作業
ID_MODELING_ARRANGE_TOOL 200000068 アレンジ
ID_MODELING_ARRAY_TOOL 450000045 配列
ID_MODELING_BEVEL_TOOL 450000005 ベベル
ID_MODELING_BRIDGE_TOOL 450000008 ブリッジ
ID_MODELING_BRUSH_TOOL 1016202 ブラシ
ID_MODELING_CENTER_TOOL 200000071 センタリング
ID_MODELING_CLONE_TOOL 450000042 クローン
ID_MODELING_CLOSEHOLE_TOOL 450000010 ポリゴンの穴を閉じる
ID_MODELING_COLLAPSE_COMMAND 1015924 つぶす
ID_MODELING_DUPLICATE_TOOL 200000067 複製
ID_MODELING_EDGECUT_TOOL 1009661 エッジカット
ID_MODELING_EDGE_SPLINE_COMMAND 1009671 エッジ選択範囲をスプラインに
ID_MODELING_EXTRUDE_INNER_TOOL 450000004 面内に押し出し
ID_MODELING_EXTRUDE_TOOL 1011183 押し出し
ID_MODELING_FILL_SELECTION_TOOL 1011178 選択範囲を満たす
ID_MODELING_FREESELECTION 200000085 投げ縄選択
ID_MODELING_IRON_TOOL 450000014 アイロン
ID_MODELING_KNIFE_TOOL 1016030 ナイフ
ID_MODELING_LIVESELECTION 200000083 ライブ選択
ID_MODELING_LOOP_TOOL 1011192 ループ選択
ID_MODELING_MAGNET_TOOL 1016185 マグネット
ID_MODELING_MATRIX_EXTRUDE_TOOL 1011126 マトリックス押し出し
ID_MODELING_MELT_COMMAND 1010136 メルト
ID_MODELING_MOVE 200000088 移動
ID_MODELING_NORMALMOVE_TOOL 450000000 法線に沿って移動
ID_MODELING_NORMALROTATE_TOOL 450000002 法線に沿って回転
ID_MODELING_NORMALSCALE_TOOL 450000001 法線に沿ってスケール
ID_MODELING_OM_SELECT_HIDE 1016208 オブジェクトを隠す
ID_MODELING_OM_SELECT_INVERT 1016207 オブジェクトの選択範囲を反転
ID_MODELING_OM_SELECT_SHOW 1016209 オブジェクトを表示
ID_MODELING_OUTLINE_SELECTION_TOOL 1011179 アウトライン選択
ID_MODELING_POINT_ADD_TOOL 450000007 ポイントを作成
ID_MODELING_POLYGON_CREATE_TOOL 450000006 ポリゴンを作成
ID_MODELING_POLYSELECTION 200000086 多角形選択
ID_MODELING_RANDOMIZE_TOOL 200000070 ランダマイズ
ID_MODELING_RECTSELECTION 200000084 長方形選択
ID_MODELING_RING_TOOL 1011180 リング選択
ID_MODELING_ROTATE 200000090 回転
ID_MODELING_SCALE 200000089 スケール
ID_MODELING_SETVALUE_TOOL 200000065 ポイントの値を整列
ID_MODELING_SHORTCUT_SELECTVISIBLE 1016757 可視エレメントのみを切替
ID_MODELING_SLIDE_TOOL 450000012 滑らせる
ID_MODELING_SMOOTH_SHIFT_TOOL 450000003 スムーズシフト
ID_MODELING_SPLINE_CHAMFER_TOOL 450000043 面取り
ID_MODELING_SPLINE_PROJECT_TOOL 450000046 投影
ID_MODELING_SPLINE_ROUND_TOOL 450000039 丸める
ID_MODELING_STITCHANDSEW_TOOL 450000011 縫い合わせ
ID_MODELING_TRANSFER_TOOL 200000069 転写
ID_MODELING_WELD_TOOL 450000009 結合
ID_NGON_FORCERETRI_MENU 1016173 N-gon内部を更新
ID_NGON_REMOVE_MENU 1016174 N-gonsを削除
ID_NGON_RETRI_MENU 1016160 N-gon内部を常に更新
ID_OBJECTHANDLES_ONOFF_MENU 1016176 軸を表示
ID_OPERATORPOOL_PLUGIN 1001138 XPresso プール
ID_SCALEDOCUMENT_CMD 200000277 プロジェクトをスケール...
ID_SDS_DEC_MENU 1016178 HyperNURBSの分割数を減少
ID_SDS_INC_MENU 1016177 HyperNURBSの分割数を増加
ID_SDS_ONFFF_MENU 1016179 Isoline 編集
ID_TREEVIEW_PLUGIN 1001145 XPresso マネージャ
ID_TRIMMEDSURFACE 1015546 IGESトリムドサーフェイス
一部、あ、ここに突っ込むIDじゃなかったかな、みたいなのもなんとなくありますが。
というかIDと内容の対応もどこか探せば書いてありそうですが。
まとめ
くたびれたのでこのあたりで
SDKなのでそんなにフレンドリーじゃないです(偏見
そういえばかつて、
Cinema4DのPython環境を解説しつつ
実はPython(およびオープンソース文化)のことをこき下ろす、というロックな記事があった気がしますが、
あれどうなんでしょうね(遠い目
はたしてPythonが悪かったのかな?????????
「op」が何なのかについて、明示的に言及したドキュメントてどっかないですかね。
探そう。
備考
ドキュメントにある関数の実行
引数に、idとか数値を要求するのがよく登場しますが、
どんな数字入れるんじゃい!って感じです。
だいたいはすぐ下に表があり、その項目名に「c4d.」ってつければID得られるっぽいです。(冒頭のc4d.VERSIONTYPE_BROADCASTも同様)
def main():
gui.MessageDialog('Hello World!')
gui.MessageDialog('Hello World!',c4d.GEMB_YESNOCANCEL)
print c4d.GEMB_YESNOCANCEL # -> 3
gui.MessageDialog( str(c4d.GEMB_YESNOCANCEL),3 )
スクリプトマネージャで新規したら書かれてる関数に、3行足しました。
図は三つ目のダイアログが表示されてるところ。
スクリプトマネージャとコマンドライン
スクリプトマネージャで新規にコードを書くのもいいですが、
これだとコンソールに実行したスクリプトが出力されません。
(それが望ましいってのもありますが)
コマンドラインから実行すると、実行した内容もコンソールに出力されます。
頭に[OK]って付きますが。
ところでスクリプトマネージャってアンドゥ効かないんです?それって鬼じゃなくって?
参考
c4d module
https://developers.maxon.net/docs/Cinema4DPythonSDK/html/modules/c4d/index.html
c4d.GetC4DVersion
https://developers.maxon.net/docs/Cinema4DPythonSDK/html/modules/c4d/index.html#c4d.GetC4DVersion
c4d.documents.BaseDocument (= doc)
https://developers.maxon.net/docs/Cinema4DPythonSDK/html/modules/c4d.documents/BaseDocument/index.html#c4d.documents.BaseDocument
c4d.BaseObject (= op)
https://developers.maxon.net/docs/Cinema4DPythonSDK/html/modules/c4d/C4DAtom/GeListNode/BaseList2D/BaseObject/index.html#c4d.BaseObject
Command Handler
https://developers.maxon.net/docs/Cinema4DPythonSDK/html/modules/c4d/index.html#command-handler
c4d.gui.MessageDialog
https://developers.maxon.net/docs/Cinema4DPythonSDK/html/modules/c4d.gui/index.html#c4d.gui.MessageDialog
cookbook
https://developers.maxon.net/docs/Cinema4DPythonSDK/html/misc/cookbook.html
例文が載ってるよ2つほど
Examples
https://github.com/PluginCafe/cinema4d_py_sdk
githubにサンプルが置かれてます。