python and settings

Maxon Cinema 4D (Export script developed by abstrax, Integrated Plugin developed by aoktar)

Moderators: ChrisHekman, aoktar

1Lyubomir
Licensed Customer
Posts: 3
Joined: Tue Apr 16, 2013 1:58 pm

I'm new to scripting. Could you tell me how to set and get values from "Octane settings" window (Kernel) using python??
User avatar
aoktar
Octane Plugin Developer
Posts: 16063
Joined: Tue Mar 23, 2010 8:28 pm
Location: Türkiye
Contact:

Are you happy to see a little c++ code?
Octane For Cinema 4D developer / 3d generalist

3930k / 16gb / 780ti + 1070/1080 / psu 1600w / numerous hw
salmon
Licensed Customer
Posts: 42
Joined: Sun Jun 30, 2013 3:50 pm

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

:)
Ok, sorry. All settings is on a object. Which is named "myOctaneSettings" and hidden.
You can find it and get BaseContainer. code is "BaseContainer *bc = paramObject->GetDataInstance()" Which is similar in phyton.

You should know all parameters with Id and types also. I can post a c++ to see this parameters. like this

Code: Select all

  /// ---------------  DirectLighting  Kernel---------------
        DlGIMod         =   bc->GetLong( SET_DIRECT_GIMOD, 4);
        DLAODist        =   (float) bc->GetReal(SET_DIRECT_AODIST, 5.0);
        DlMaxSamples    =   bc->GetLong( SET_DIRECT_MAXSAMPLES, 128);
        DlDifDepth      =   bc->GetLong( SET_DIRECT_DIFDEPTH, 2);
        DlGlosDepth     =   bc->GetLong( SET_DIRECT_GLOSDEPTH, 2);
        DlFsize         =   (float) bc->GetReal( SET_DIRECT_FSIZE, 1.2);

Octane For Cinema 4D developer / 3d generalist

3930k / 16gb / 780ti + 1070/1080 / psu 1600w / numerous hw
1Lyubomir
Licensed Customer
Posts: 3
Joined: Tue Apr 16, 2013 1:58 pm

Thank you! But one more question. How to refresh "Octane Settings" window after setting new values?
User avatar
LudovicRouy
Licensed Customer
Posts: 216
Joined: Sat Apr 03, 2010 5:05 pm
Location: FRANCE
Contact:

Here is a script to put in a python script tag (sorry I don't know how to force indentation in post replace * by tab):

import c4d

def main():
* op[c4d.EXPRESSION_ENABLE]=0
* octSet = 0
* oLst = doc.GetObjects()
* for i in oLst :
** if i.GetName()=="myOctaneSettings":
*** octSet = i.GetDataInstance()
* if octSet :
** print " GI mode : " + str(octSet[c4d.SET_DIRECT_GIMOD])
** print " AO distance : " + str(octSet[c4d.SET_DIRECT_AODIST])
** print " Max samples : " + str(octSet[c4d.SET_DIRECT_MAXSAMPLES])
** print " Diffuse depth : " + str(octSet[c4d.SET_DIRECT_DIFDEPTH])
** print " Glossy depth : " + str(octSet[c4d.SET_DIRECT_GLOSDEPTH])
** print " Filter size : " + str(octSet[c4d.SET_DIRECT_FSIZE])

Hope this will help other python coders

Thanks to Ahmet and his c++ settings ;)
1Lyubomir
Licensed Customer
Posts: 3
Joined: Tue Apr 16, 2013 1:58 pm

LudovicRouy wrote:Here is a script to put in a python script tag (sorry I don't know how to force indentation in post replace * by tab):
Good script. Thanks.
But when I write my own value to settings like: octSet[c4d.SET_DIRECT_MAXSAMPLES]=2000.0
setting changes but in Octane Settings window nothing happens and c4d.EventAdd() useless
User avatar
LudovicRouy
Licensed Customer
Posts: 216
Joined: Sat Apr 03, 2010 5:05 pm
Location: FRANCE
Contact:

Yes, i didn't know how to update the settings window

BUT if you close it, execute your script then reopen it, you'll see that settings are changed and updated.

Or as you know the keys you can close the window run your script and just use the print statement to verify updates.

Please Ahmet could you post other c++ settings ?
User avatar
aoktar
Octane Plugin Developer
Posts: 16063
Joined: Tue Mar 23, 2010 8:28 pm
Location: Türkiye
Contact:

All command is in txt file. I don't know a way to force updates on external dialog.But IDD_SETTINGS_DIALOG is id for settings dialog. Also you can see all values in "vprender.h" and "c4d_symbols.h".
Setting ID's are also same on Octane render settings.
Attachments
settings.txt
(6.2 KiB) Downloaded 489 times
Octane For Cinema 4D developer / 3d generalist

3930k / 16gb / 780ti + 1070/1080 / psu 1600w / numerous hw
User avatar
LudovicRouy
Licensed Customer
Posts: 216
Joined: Sat Apr 03, 2010 5:05 pm
Location: FRANCE
Contact:

Thanks Ahmet,

Its a good starting point ;)
Post Reply

Return to “Maxon Cinema 4D”