Page 4 of 7
Re: ==== Octane useful scripts ====
Posted:
Wed Jan 18, 2023 5:48 am
by aoktar
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()
Re: ==== Octane useful scripts ====
Posted:
Wed Jan 18, 2023 11:08 am
by ShivaMist
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
Re: ==== Octane useful scripts ====
Posted:
Wed Jan 18, 2023 8:14 pm
by aoktar
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
Re: ==== Octane useful scripts ====
Posted:
Thu Jan 19, 2023 8:49 am
by ShivaMist
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
Re: ==== Octane useful scripts ====
Posted:
Thu Jan 19, 2023 9:18 am
by aoktar
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?
Re: ==== Octane useful scripts ====
Posted:
Thu Jan 19, 2023 10:23 am
by ShivaMist
Yes now it works even if Octane has not been activated/initialized thank you very much!
Re: ==== Octane useful scripts ====
Posted:
Thu Jan 26, 2023 8:44 am
by lionlee19
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
Re: ==== Octane useful scripts ====
Posted:
Mon Jan 30, 2023 4:38 pm
by lionlee19
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
Re: ==== Octane useful scripts ====
Posted:
Wed Mar 08, 2023 12:52 pm
by aoktar
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()
Re: ==== Octane useful scripts ====
Posted:
Wed Aug 23, 2023 11:12 am
by SSmolak
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.