==== Octane useful scripts ====

Forums: ==== Octane useful scripts ====
Sub forum for help and tutorials.

Moderator: aoktar

Re: ==== Octane useful scripts ====

Postby aoktar » Wed Jan 18, 2023 5:48 am

aoktar Wed Jan 18, 2023 5:48 am
ShivaMist wrote:Is this topic dead ?

Try this

Code: Select all
from typing import Optional
import c4d

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

def main() -> None:
    # Called when the plugin is selected by the user. Similar to CommandData.Execute.
    rd = doc.GetActiveRenderData()
    vpost = rd.GetFirstVideoPost()
    OctaneRender_ID = 1029525
    octVp=None

    while vpost:  # search OctaneRender
        #print(vpost)
        if vpost.GetName() == "Octane Renderer": octVp=vpost
        vpost = vpost.GetNext()
       
    if octVp is None:  #Create new Octane Render
        rd[c4d.RDATA_RENDERENGINE] = OctaneRender_ID
        rd.InsertVideoPostLast(c4d.documents.BaseVideoPost(OctaneRender_ID))
       
        bc = rd.GetDataInstance()
        bc[c4d.RDATA_RENDERENGINE] = OctaneRender_ID   # set OctaneRender as active renderer
       
        print('Added Octane VideoPost')
        c4d.EventAdd()
    else:
        print('We have Octane VideoPost')
        bc = rd.GetDataInstance()
        bc[c4d.RDATA_RENDERENGINE] = OctaneRender_ID  #switch to Octane
        c4d.EventAdd()


if __name__ == '__main__':
    main()
Last edited by aoktar on Wed Jan 18, 2023 8:15 pm, edited 1 time in total.
Octane For Cinema 4D developer / 3d generalist

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

Re: ==== Octane useful scripts ====

Postby ShivaMist » Wed Jan 18, 2023 11:08 am

ShivaMist Wed Jan 18, 2023 11:08 am
Thank you for the answer Aoktar!

I've tried the code you provided, it works if Octane has been activated before, but not on a default c4d, i think it has something to do with the Octane Init and activation, i have attached a video showing the different behaviors. The point of this script is for my studio's pipeline to be able to initialize scenes renderer depending on the project
Attachments

[ Play Quicktime file ] octane video post 2023-01-18 12-04-23.mp4 [ 1.4 MiB | Viewed 16096 times ]

ShivaMist
Licensed Customer
Licensed Customer
 
Posts: 75
Joined: Thu Oct 11, 2018 5:07 pm
Location: Paris

Re: ==== Octane useful scripts ====

Postby aoktar » Wed Jan 18, 2023 8:14 pm

aoktar Wed Jan 18, 2023 8:14 pm
ShivaMist wrote:Thank you for the answer Aoktar!

I've tried the code you provided, it works if Octane has been activated before, but not on a default c4d, i think it has something to do with the Octane Init and activation, i have attached a video showing the different behaviors. The point of this script is for my studio's pipeline to be able to initialize scenes renderer depending on the project

Delete line 20! It's not hard to find errors if you check the messages
Octane For Cinema 4D developer / 3d generalist

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

Re: ==== Octane useful scripts ====

Postby ShivaMist » Thu Jan 19, 2023 8:49 am

ShivaMist Thu Jan 19, 2023 8:49 am
It was indeed line 22 that was causing errors! Thanks for pointing out that error, i know it's not that "hard" but as i am a beginner in python and dev, the error was not really understandable from the console. That's why i came here for help :)
ShivaMist
Licensed Customer
Licensed Customer
 
Posts: 75
Joined: Thu Oct 11, 2018 5:07 pm
Location: Paris

Re: ==== Octane useful scripts ====

Postby aoktar » Thu Jan 19, 2023 9:18 am

aoktar Thu Jan 19, 2023 9:18 am
ShivaMist wrote:It was indeed line 22 that was causing errors! Thanks for pointing out that error, i know it's not that "hard" but as i am a beginner in python and dev, the error was not really understandable from the console. That's why i came here for help :)

Understand, I forgot this trial line. I've thought to add undo at moment. I think it's OK?
Octane For Cinema 4D developer / 3d generalist

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

Re: ==== Octane useful scripts ====

Postby ShivaMist » Thu Jan 19, 2023 10:23 am

ShivaMist Thu Jan 19, 2023 10:23 am
Yes now it works even if Octane has not been activated/initialized thank you very much!
ShivaMist
Licensed Customer
Licensed Customer
 
Posts: 75
Joined: Thu Oct 11, 2018 5:07 pm
Location: Paris

Re: ==== Octane useful scripts ====

Postby lionlee19 » Thu Jan 26, 2023 8:44 am

lionlee19 Thu Jan 26, 2023 8:44 am
1. Is there a way to get the selected nodes in Node Editor via python?
I want to do some operations on the nodes that are selected by user

Also, I know GetDown() can get the FIRST child node, but
2. how can I get the subsequent child nodes?

Thank you
lionlee19
Licensed Customer
Licensed Customer
 
Posts: 10
Joined: Sat Nov 30, 2019 10:26 am

Re: ==== Octane useful scripts ====

Postby lionlee19 » Mon Jan 30, 2023 4:38 pm

lionlee19 Mon Jan 30, 2023 4:38 pm
Hi, I am using python script to create a OSL texture node and load the OSL script from external file.
I am able to set these two parameters. But it seems the OSL do not compile and the parameters for the OSL script donot show up. How can I press the Reset&Compile button and Glsl->Osl button via python script?
Thank you
lionlee19
Licensed Customer
Licensed Customer
 
Posts: 10
Joined: Sat Nov 30, 2019 10:26 am

Re: ==== Octane useful scripts ====

Postby aoktar » Wed Mar 08, 2023 12:52 pm

aoktar Wed Mar 08, 2023 12:52 pm
Example script from reading the Octane preferences

Code: Select all
import c4d
from c4d import gui

ID_OCTANE_LIVEPLUGIN = 1029499

def main():
    bc = doc[ID_OCTANE_LIVEPLUGIN] 
    data = c4d.plugins.GetWorldPluginData(ID_OCTANE_LIVEPLUGIN)
    print("data",data[13])  #OPENGL_SAMPLES
    print("data",data[85])  #PREFS_LOCALDB_PATH
    print("data",data[70])  #PREFS_NG_CAT_MAT_COLOR
   
    octPrefs = data[131]
    print("OCIO_USEOTHERCFG:",octPrefs[5])  #OCIO_USEOTHERCFG
    print("OCIO_INTERM_GUESS:",octPrefs[7])  #OCIO_INTERM_GUESS
    print("OCIO_CFG_FILE:",octPrefs[1])  #OCIO_CFG_FILE
   
   
    print ("Octane version=",bc[30])     
    print ("Octane version=",bc[c4d.SET_OCTANE_VERSION])
    print ("Lock resolution=", bc[c4d.SET_LOCKRES])
    print ("Check camera updates=", bc[c4d.SET_CHECK_CAMERA])
    print ("Default environment color=", bc[c4d.SET_DEF_ENV_COLOR])

    print ("Kernel tip=", bc[c4d.SET_KERNEL_TYPE])
    print ("DL Max samples=", bc[c4d.SET_DIRECT_MAXSAMPLES])
    print ("PT Max samples=", bc[c4d.SET_PATHTRACE_MAXSAMPLES])


if __name__=='__main__':
    main()
Octane For Cinema 4D developer / 3d generalist

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

Re: ==== Octane useful scripts ====

Postby SSmolak » Wed Aug 23, 2023 11:12 am

SSmolak Wed Aug 23, 2023 11:12 am
aoktar wrote:This script is for resetting the Compression of ImageTexture to "Automatic". You can freely change it for different compression values or selected materials.


Is there way to change compression only for textures that have "diffuse" in their name for example ? Unfortunately change compression globally for selected textures in Octane Texture Manager is not possible for many of them selected - it ask for every texture.
Architectural Visualizations http://www.archviz-4d.studio
User avatar
SSmolak
Licensed Customer
Licensed Customer
 
Posts: 1095
Joined: Sat Feb 07, 2015 5:41 pm
Location: Poland
PreviousNext

Return to Help / Tutorials


Who is online

Users browsing this forum: No registered users and 9 guests

Sat Apr 27, 2024 3:12 pm [ UTC ]