==== Octane useful scripts ====

Sub forum for help and tutorials.

Moderators: ChrisHekman, aoktar

User avatar
aoktar
Octane Plugin Developer
Posts: 16063
Joined: Tue Mar 23, 2010 8:28 pm
Location: Türkiye
Contact:

Delizade wrote:Hello,
is it possible to create shortcut via python for "Auto Arrange Selected". If we can use octane functions via python it must be possible. Could you anyone knows anything about this?
for example I know we can add octane nodes via python so I thought that maybe we can use some menu commands as well.

thank you
This is an internal function and they needs to be exposed to python interface. Creating the nodes are done by as creating C4D materials or textures because they are just defined plugins by some ID. Both are not same.
Octane For Cinema 4D developer / 3d generalist

3930k / 16gb / 780ti + 1070/1080 / psu 1600w / numerous hw
User avatar
aoktar
Octane Plugin Developer
Posts: 16063
Joined: Tue Mar 23, 2010 8:28 pm
Location: Türkiye
Contact:

DunHou wrote:yes ,Delizade is right. I also wang to a "Auto Arrange Selected" button.and a lot of setting in python i cannot find in octane,Now in 2021version,aov system seems not work with old pipline,and i cant fix it with py scripts.will octane post a sdk or provide a scirpts exsample .
Thanks
It's now different than older one to provide the new flexible way for AOVs. See following c++ example, it's showing how I'm adding one AOV under to Octane VideoPost data. Here "parent" is Octane VideoPostData.

Code: Select all

BaseList2D *addAOVnode(BaseList2D *parent, Int32 slotID, Int32 TYPE, Octane::RenderPassId passId, Bool incCnt)
{
    BaseContainer *bc = parent->GetDataInstance();
    Int32 pType = bc->GetInt32(AOV_NODE_TYPE);

    BaseList2D *shd = addOctaneShaderToNode(parent, slotID, ID_OCTANE_AOV_NODE);

    if(TYPE==AOV_TYPE_COMP_GROUP)       {  shd->SetName(AOV_GROUP_NAME);  }
    else if(TYPE==AOV_TYPE_COMP_AOV)         {  shd->SetName(AOV_COMP_NAME);  }
    else if(TYPE==AOV_TYPE_COMP_AOV_LAYER)   {  shd->SetName(AOV_COMPLAYER_NAME);  }
    else if(TYPE==AOV_TYPE_COLOR_OUT)        {  shd->SetName(AOV_COLOROUT_NAME);  }
    else if(TYPE==AOV_TYPE_IMAGE_AOV_OUT)    {  shd->SetName(AOV_IMAGEOUT_NAME);  }
    else if(TYPE==AOV_TYPE_COMP_LIGHTMIXER)  {  shd->SetName(AOV_IMAGEOUT_NAME);  }
    else if(TYPE==AOV_TYPE_RENDER_AOV_OUT)
    {
        shd->SetParameter(DescLevel(AOV_RENDER_PASS_ID), GeData((Int32)passId), DESCFLAGS_SET_0);
        shd->SetName(AOV_RENDEROUT_NAME+S(":[")+Octane::ApiInfo::renderPassName(passId)+"]");
    }

    setParameterLong(*shd, AOV_NODE_TYPE, TYPE);
    if(incCnt)
    {
        Int32 cnt = bc->GetInt32(AOV_INPUT_COUNT);
        setParameterLong(*parent, AOV_INPUT_COUNT, cnt+1);
    }
    return shd;
}
Octane For Cinema 4D developer / 3d generalist

3930k / 16gb / 780ti + 1070/1080 / psu 1600w / numerous hw
User avatar
aoktar
Octane Plugin Developer
Posts: 16063
Joined: Tue Mar 23, 2010 8:28 pm
Location: Türkiye
Contact:

freakanay wrote:Hi people!

I've been struggling with this for a while, and I still cannot find the correct way to do it: I would like to get current rendering information of my scene that's using Octane - things like what frame the render is currently on, how long it took to render per frame, etc.
I see in the console all the Octane info and basically, I just want the same info but through the Python terminal.

Does anyone know the right syntaxes for this?!

Thanks a bunch!
There's not any communication to read internal function for partial render times for several render processes. You may read estimated render time as how you do with Standard Renderer.
Octane For Cinema 4D developer / 3d generalist

3930k / 16gb / 780ti + 1070/1080 / psu 1600w / numerous hw
User avatar
Delizade
Licensed Customer
Posts: 180
Joined: Thu Oct 18, 2018 10:38 pm
Location: Istanbul

Hello,

If you work with many materials and if you edit materials frequently
this script brings material into Octane Node Editor directly without additional clicks.
Assigning a shortcut makes easier workflow.
Select_Active_Object_Material_In_NodeEditor.zip
(537 Bytes) Downloaded 482 times
User avatar
aoktar
Octane Plugin Developer
Posts: 16063
Joined: Tue Mar 23, 2010 8:28 pm
Location: Türkiye
Contact:

This script is for resetting the Compression of ImageTexture to "Automatic". You can freely change it for different compression values or selected materials.

Code: Select all

from typing import Optional
import c4d
from c4d import gui

doc: c4d.documents.BaseDocument  # The active document
op: Optional[c4d.BaseObject]  # The active object, None if unselected

ID_OCTANE_IMAGE_TEXTURE = 1029508

def collect(shdList, n):
    
    if n==None: return
    
    if n.GetType()==ID_OCTANE_IMAGE_TEXTURE: 
        ix=-1
        try:
            ix = shdList.index(n)
        except:
            ix=-1

        if ix==-1:  shdList.append(n)

    if n.GetDown(): collect(shdList, n.GetDown())
    if n.GetNext(): collect(shdList, n.GetNext())


def main() -> None:
    # Called when the plugin is selected by the user. Similar to CommandData.Execute.
    matList = doc.GetMaterials()
    
    for mat in matList:
        
        shaders = []
        collect(shaders, mat.GetFirstShader())
   
        for n in shaders:
            n[c4d.IMAGETEX_COMPR_FORMAT]=0  #reset the compression
       
        c4d.EventAdd()   

if __name__ == '__main__':
    main()
Attachments
reset-image-compression.zip
(715 Bytes) Downloaded 462 times
Octane For Cinema 4D developer / 3d generalist

3930k / 16gb / 780ti + 1070/1080 / psu 1600w / numerous hw
User avatar
aoktar
Octane Plugin Developer
Posts: 16063
Joined: Tue Mar 23, 2010 8:28 pm
Location: Türkiye
Contact:

Here's another script. It's for finding OctaneRender videopost and reading the AOVs from "render AOV group".
Attachments
readOctaneVpost.zip
(776 Bytes) Downloaded 438 times
Octane For Cinema 4D developer / 3d generalist

3930k / 16gb / 780ti + 1070/1080 / psu 1600w / numerous hw
silanbekjarov
Licensed Customer
Posts: 35
Joined: Tue Apr 13, 2021 12:52 pm

Hi @aoktar I`ve posted in a few other posts about my problem Im trying to solve rn mid-production... I have octane materials, their real paths are correct and in the suggested file path is only the file name of the file. This way the native project asset inspector is showing the texture as missing. But if I change the filepath to absolut in the image texture node or just put the "real path" in the "suggested path" in the octane texture manager it automatically has the texture found in the native c4d project asset inspector.

could you maybe help me with a script that changes the relative path (filename) to the absolute path (full path). I`d really appreciate any help from anyone reading this, as Im kinda trying to solve this to be able to render..

Thanks a lot.
<3
User avatar
aoktar
Octane Plugin Developer
Posts: 16063
Joined: Tue Mar 23, 2010 8:28 pm
Location: Türkiye
Contact:

silanbekjarov wrote:Hi @aoktar I`ve posted in a few other posts about my problem Im trying to solve rn mid-production... I have octane materials, their real paths are correct and in the suggested file path is only the file name of the file. This way the native project asset inspector is showing the texture as missing. But if I change the filepath to absolut in the image texture node or just put the "real path" in the "suggested path" in the octane texture manager it automatically has the texture found in the native c4d project asset inspector.

could you maybe help me with a script that changes the relative path (filename) to the absolute path (full path). I`d really appreciate any help from anyone reading this, as Im kinda trying to solve this to be able to render..

Thanks a lot.
<3
Help me understand why do you need it! It should not be any problems what you see in texture managers. Render manager will know where to find the textures. Looks to directories under the project for first, later will check the texture search paths. It doesn't any matter if texture dialogs do show they are missing.
Octane For Cinema 4D developer / 3d generalist

3930k / 16gb / 780ti + 1070/1080 / psu 1600w / numerous hw
ShivaMist
Licensed Customer
Posts: 80
Joined: Thu Oct 11, 2018 5:07 pm
Location: Paris

Rookie wrote:Hi :
I am working on my tool set,but i cannot switch render engine to octane correct. (C4D R24+octane 2020.2.3.R6)
the render engine in the drop down (render settings) is named Octane render,

but there is no "post effect" octane in the post effect list

If you have a new Document and you switch to octane render by hand and then back to standard by hand. and after that execute the script. the "post effect" octane will be there and the render will be the one to render.

Is there a right/better way to switch to octane. so that it works even if the user did not switch back before by hand?

wish your help plz


Code: Select all

import c4d 

def main() : 
rdata = doc.GetActiveRenderData() 
vpost = rdata.GetFirstVideoPost() 
OctaneRender_ID = 1029525 
rdata[c4d.RDATA_RENDERENGINE] = OctaneRender_ID 

on = False 

while vpost: 
if vpost.CheckType(c4d.VPxmbsampler) : 
on = True 
vpost = vpost.GetNext() 

if on == False: 
vpost = c4d.BaseList2D(c4d.VPxmbsampler) 
rdata.InsertVideoPost(vpost) 

c4d.EventAdd() 

main()
I'm experiencing the same issue trying to make a script to setup different render engines and render settings, the only workaround is to use a file with render settings already set on Octane Render by hand. Anybody got around this issue ?
ShivaMist
Licensed Customer
Posts: 80
Joined: Thu Oct 11, 2018 5:07 pm
Location: Paris

Is this topic dead ?
Post Reply

Return to “Help / Tutorials”