Dumping an object to Python code

On 23/08/2016 at 06:47, xxxxxxxx wrote:

Hi there,
I wonder whether there is a mean to dump a selected object (a shader for instance) to Python code.
Apart from a didactic goal, the aim would be to speed up code template creation; for instance, from a shader defined through UI, deriving variations in Python code.
Such a tool would likely be a plugin that to introspection on c4D objects. Does it exists yet ?

On 24/08/2016 at 06:20, xxxxxxxx wrote:


introspection in Python sense is not possible, at least not to the extend you expect.

But you can create/clone objects and modify them (you probably know this) :

obj = c4d.BaseObject(c4d.Osphere)
obj[parameter id] = ...

You can also browse the BaseContainer of an object (but there's a certain risk, some data might not be stored in the BaseContainer) :

for index, value in obj.GetDataInstance() :
    print(index, value)

And finally you can browse the Description of objects, see code at the bottom of the page.

I hope this helps.