On 06/01/2013 at 09:57, xxxxxxxx wrote:
Hello dear Community!
I'm very proud to tell you about the initial release of the c4dtools library. It is a Python package
containing classes and functions that make it easier writing plugins for Cinema 4D.
Significant features:
â–º Easily access symbols from your c4d_symbols.h file.
â–º Easily load strings from your c4d_strings.str file.
â–º Fast: Symbol-loading will be cached by default.
â–º Easily load libraries from your plugin's lib directory using a self-contained importer.
â–º Convenient wrapper for the c4d.plugins.CommandData class.
â–º Thoroughly documented code!
â–º and more..
Here's some example code:
import c4d
import c4dtools
res, importer = c4dtools.prepare(__file__)
# Import libraries from the `lib` folder relative to the plugins
# directory, 100% self-contained and independent from `sys.path`.
mylib = importer.import_('mylib')
mylib.do_stuff()
class MyDialog(c4d.gui.GeDialog) :
def CreateLayout(self) :
# Access symbols from the `res/c4d_symbols.h` file via
# the global `res` variable returned by `c4dtools.prepare()`.
return self.LoadDialogResource(res.DLG_MYDIALOG)
def InitValues(self) :
# Load strings from the `res/strings_xx/c4d_strings.str` file
# via `res.string`.
string_1 = res.string.IDC_MYSTRING_1()
string_2 = res.string.IDC_MYSTRING_2("Peter")
self.SetString(res.EDT_STRING1, string_1)
self.SetString(res.EDT_STRING2, string_2)
return True
# As of the current release, the only wrapped plugin class is
# `c4d.plugins.CommandData`. The plugin is registered automatically
# in `c4dtools.plugins.main()`, the information for registration
# is defined on class-level.
class MyCommand(c4dtools.plugins.Command) :
PLUGIN_ID = 100008 # !! Must be obtained from the plugincafe !!
PLUGIN_NAME = res.string.IDC_MYCOMMAND()
PLUGIN_HELP = res.string.IDC_MYCOMMAND_HELP()
def Execute(self, doc) :
dlg = MyDialog()
return dlg.Open(c4d.DLG_TYPE_MODAL)
# Invoke the registration of `MyCommand` via `c4dtools.plugins.main()`
# on the main-run of the python-plugin.
if __name__ == '__main__':
c4dtools.plugins.main()
You can download the c4dtools library from github here.
I will continue developing this library and wouldn't mind any forkers.
Some feedback would be nice as well, thanks!
Best,
Niklas
UPDATE: 1.1.0
The c4dtools library has been improved and is now licensed under the Simplified BSD License,
allowing it to be used in commercial projects! The documentation has been updated as well and
is included in the repository.
Grab it from github!