python and settings

Forums: python and settings
Maxon Cinema 4D (Export script developed by abstrax, Integrated Plugin developed by aoktar)

Moderator: aoktar

python and settings

Postby 1Lyubomir » Wed Oct 22, 2014 4:06 am

1Lyubomir Wed Oct 22, 2014 4:06 am
I'm new to scripting. Could you tell me how to set and get values from "Octane settings" window (Kernel) using python??
1Lyubomir
Licensed Customer
Licensed Customer
 
Posts: 3
Joined: Tue Apr 16, 2013 1:58 pm

Re: python and settings

Postby aoktar » Wed Oct 22, 2014 1:13 pm

aoktar Wed Oct 22, 2014 1:13 pm
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
User avatar
aoktar
Octane Plugin Developer
Octane Plugin Developer
 
Posts: 13591
Joined: Tue Mar 23, 2010 8:28 pm
Location: Türkiye

Re: python and settings

Postby salmon » Wed Oct 22, 2014 2:28 pm

salmon Wed Oct 22, 2014 2:28 pm
:shock:
salmon
Licensed Customer
Licensed Customer
 
Posts: 29
Joined: Sun Jun 30, 2013 3:50 pm

Re: python and settings

Postby aoktar » Wed Oct 22, 2014 2:37 pm

aoktar Wed Oct 22, 2014 2:37 pm
:)
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
User avatar
aoktar
Octane Plugin Developer
Octane Plugin Developer
 
Posts: 13591
Joined: Tue Mar 23, 2010 8:28 pm
Location: Türkiye

Re: python and settings

Postby 1Lyubomir » Sat Oct 25, 2014 12:44 am

1Lyubomir Sat Oct 25, 2014 12:44 am
Thank you! But one more question. How to refresh "Octane Settings" window after setting new values?
1Lyubomir
Licensed Customer
Licensed Customer
 
Posts: 3
Joined: Tue Apr 16, 2013 1:58 pm

Re: python and settings

Postby LudovicRouy » Sat Oct 25, 2014 8:56 am

LudovicRouy Sat Oct 25, 2014 8:56 am
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 ;)
User avatar
LudovicRouy
Licensed Customer
Licensed Customer
 
Posts: 216
Joined: Sat Apr 03, 2010 5:05 pm
Location: FRANCE

Re: python and settings

Postby 1Lyubomir » Sat Oct 25, 2014 11:56 am

1Lyubomir Sat Oct 25, 2014 11:56 am
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
1Lyubomir
Licensed Customer
Licensed Customer
 
Posts: 3
Joined: Tue Apr 16, 2013 1:58 pm

Re: python and settings

Postby LudovicRouy » Sat Oct 25, 2014 12:59 pm

LudovicRouy Sat Oct 25, 2014 12:59 pm
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
LudovicRouy
Licensed Customer
Licensed Customer
 
Posts: 216
Joined: Sat Apr 03, 2010 5:05 pm
Location: FRANCE

Re: python and settings

Postby aoktar » Sat Oct 25, 2014 3:04 pm

aoktar Sat Oct 25, 2014 3:04 pm
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 182 times
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: 13591
Joined: Tue Mar 23, 2010 8:28 pm
Location: Türkiye

Re: python and settings

Postby LudovicRouy » Sun Oct 26, 2014 7:32 am

LudovicRouy Sun Oct 26, 2014 7:32 am
Thanks Ahmet,

Its a good starting point ;)
User avatar
LudovicRouy
Licensed Customer
Licensed Customer
 
Posts: 216
Joined: Sat Apr 03, 2010 5:05 pm
Location: FRANCE
Next

Return to Maxon Cinema 4D


Who is online

Users browsing this forum: No registered users and 14 guests

Sat Sep 26, 2020 7:22 pm [ UTC ]