Pipeline integration



  • Hi,

    I'm trying to configure C4d at startup/newScene to match the current project specs in python.
    I see there is the possibility of running python_init.py at startup, but it seems completely useless because no doc has been created yet and it is not possible to change stuff for the scene (e.g. set renderer to Redshift)
    Another possibility would be to have a "new.c4d" and have our launcher copy it to the userfolder before startup, but then all settings would be static and I can't set anything project specific (e.g. renderoutput).
    How do people tackle stuff like this?
    Thanks!



  • Hi, @knekke first of all welcome in the plugin cafe community!

    No worries at all since it's your first post here, but please make sure to read and apply the rules defined on the following topics:

    I've set up your topic correctly, by marking it as a question adding tags and move it to the correct category.

    With that's said regarding your question, a doc variable is available, in the python_init.py (take care python_init.py is no more loaded in Cinema 4D R20).
    But as you already figured it out, this doc is more or less useless (it can be used to do some stuff), but since python_init.py is called very early, the document is replaced by the new.c4d file afterward.
    So any change made in the doc provided with python_init.py are lost.

    But what you could do is write a PluginMessage plugin and react to C4DPL_PROGRAM_STARTED.
    Here a basic example which adds a cube to the scene.
    Create a *.pyp file in the plugin folder of cinema c4d and past the following code.

    import c4d
    
    def PluginMessage(id, data):
        if id==c4d.C4DPL_PROGRAM_STARTED:
            doc = c4d.documents.GetActiveDocument()
            doc.InsertObject(c4d.BaseObject(c4d.Ocube))
    

    Cheers,
    Maxime.



  • @m_adam thanks for fixing the post. Next one will be better, I promise :)

    That snippet looks like it should do the trick. There is no message for newSceneCreated, but I guess I could just save a new.c4d at the end of my startup procedure.

    Thanks,
    Thomas



  • Hi Thomas,

    There is MSG_DOCUMENTINFO. And this message is available in python.

    def Message(id, data):
        if id == c4d.MSG_DOCUMENTINFO:
            if not data: return True
            if data["type"] = c4d.MSG_DOCUMENTINFO_TYPE_LOAD:
                print "newDoc"
    

    Unfortunately, there is no way to get this message called in C4D, since Python object which supports and receive a Message function are all scene dependants (like Tag, ObjectData).
    In C++ we do have the SceneHook NodeData plugin which allows this kind of stuff since it's a global NodeData, not attached to a special document.

    So your idea is probably the best way to go if you stick to python.
    Cheers,
    Maxime.



  • @m_adam said in Pipeline integration:

    c4d.C4DPL_PROGRAM_STARTED

    Has something changed in R20 regarding plugin load order or program_started execution time?
    I used a startup script to change the renderer to redshift, but while it works in R19 it doesn't in R20.



  • @knekke said in Pipeline integration:

    Has something changed in R20 regarding plugin load order or program_started execution time?
    I used a startup script to change the renderer to redshift, but while it works in R19 it doesn't in R20.

    @m_adam said in Pipeline integration:

    (take care python_init.py is no more loaded in Cinema 4D R20).

    C4DPL_PROGRAM_STARTED is working as before, only the python_init.py is no more called in R20 SP1 (This will be fixed in R20 SP2).

    Cheers,
    Maxime.



  • @m_adam said in Pipeline integration:

    C4DPL_PROGRAM_STARTED is working as before

    Ok, but why:

    import c4d
    
    def PluginMessage(id, data):
        if id==c4d.C4DPL_PROGRAM_STARTED:
            doc = c4d.documents.GetActiveDocument()
            doc.InsertObject(c4d.BaseObject(c4d.Ocube)) # Works
            doc[c4d.RDATA_RENDERENGINE] = 1036219 #redshift   Doesn't Work
    

    ?



  • Because you didn't insert the actual renderer: InsertVideoPost()
    BaseVideoPost