Page 5 of 7

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

PostPosted: Wed Aug 23, 2023 11:42 am
by ShivaMist
SSmolak wrote: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.


Code: Select all
import c4d
ID_OCTANE_IMAGE_TEXTURE = 1029508

def collect(shdList, n):
    if n is 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():
    doc = c4d.documents.GetActiveDocument()
    matList = doc.GetMaterials()
    for mat in matList:
        shaders = []
        collect(shaders, mat.GetFirstShader())
        for shader in shaders:
            if 'diffuse' in shader[c4d.IMAGETEXTURE_FILE].lower():
                shader[c4d.IMAGETEX_COMPR_FORMAT] = 0

if __name__ == '__main__':
    main()


Here you go!

This line is where you choose the parameter, you can use trial and error :)
Code: Select all
shader[c4d.IMAGETEX_COMPR_FORMAT] = 0

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

PostPosted: Wed Aug 23, 2023 11:50 am
by SSmolak
ShivaMist wrote:
Here you go!


Thank you very much. That's fantasitc !

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

PostPosted: Wed Nov 22, 2023 11:52 am
by Hurricane046
EDIT: Nevermind, solved!

Code: Select all
# -------------------------------------------------------------
# SET SPECULAR VALUES

def main():
    materials = doc.GetMaterials()
    for material in materials:
        red = 0.0
        green = 0.0
        blue = 0.0
        material[c4d.OCT_MATERIAL_DIFFUSE_FLOAT]=1
        material[c4d.OCT_MATERIAL_SPECULAR_FLOAT]=0.3
        material[c4d.OCT_MATERIAL_SPECULAR_COLOR]=c4d.Vector(red, green, blue)
    c4d.EventAdd()

main()


Is there a Python way to:

• set the HSV values to 0,0,0
• set the Float value to 0.5

We've already written extensive script which handles a lot of Octane related stuff for us but accessing these properties is proving to be troublesome. Thank you!

Image

It doesn't turn orange so I assume there is more tricky way of accessing this property. The OCT_MATERIAL_DIFFUSE_FLOAT works.

Image

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

PostPosted: Thu Nov 23, 2023 8:39 am
by Hurricane046
I'm looking for script which will force reload of ALL Octane Material thumbnails in the current project.

I'm using Aoktar's script for reloading individually selecteded material thumbnail but I'm having trouble to automate this process for all materials since the script needs to take around 1 second break between each material so the preview is able to properly render. As far as I know this isn't possible without asyncio?

This is what I'm using now:

Code: Select all
import c4d
from c4d import gui

ID_OCTANE_IMAGE_TEXTURE = 1029508

def collect(shdList, n):
    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():
    mat = doc.GetActiveMaterial()
    shaders=[]

    collect(shaders, mat.GetFirstShader())
   
    for n in shaders:
        n[c4d.IMAGETEXTURE_FORCE_RELOAD]=1
        n.SetDirty(c4d.DIRTYFLAGS_ALL)
   
    c4d.EventAdd()   

if __name__=='__main__':
    main()

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

PostPosted: Tue Dec 05, 2023 9:17 am
by Hurricane046
Hello, I can't intercept CallCommand for "Remove duplicate material". It intercepts the one for "Convert Materials" but not for the removal.

Any chance anyone here knows what the ID on this CallCommand is? Thank you!

Image

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

PostPosted: Mon Dec 11, 2023 12:15 pm
by aoktar
[quote="Hurricane046"]Hello, I can't intercept CallCommand for "Remove duplicate material". It intercepts the one for "Convert Materials" but not for the removal.

Any chance anyone here knows what the ID on this CallCommand is? Thank you!

You can look for commands in Commander(shift+C)
ID_REMOVE_UNUSED_MATERIALS=1035351
ID_REMOVE_DUPLICATED_MATERIALS=1036468

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

PostPosted: Mon Dec 11, 2023 1:39 pm
by Hurricane046
Thanks for the answer! Unfortunately it seems that Remove duplicate material isn't your average Python c4d.CallCommand().

Remove Unused Materials
c4d.CallCommand(1035351) does work.

Remove duplicate material
c4d.CallCommand(1036468) doesn't work.

I cannot even find the "Remove duplicate material" Octane function in the shift+C list. It only shows these two where one is the Remove Unused Materials function and the other is my Python script.

Image

Is there any way this function can be called via Python script? Out of 30 various functions we've already implemented, this one is throwing a wrench in the whole thing. :?

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

PostPosted: Tue Dec 12, 2023 8:18 am
by SSmolak
Hurricane046 wrote:
I cannot even find the "Remove duplicate material"


Shift+F12 type "unused" "duplicated" and you will have all commands listed here

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

PostPosted: Tue Dec 12, 2023 8:58 am
by Hurricane046
I did that but this window also doesn't show the Octane function "Remove duplicate material". It shows the native C4D one "Delete Duplicate Materials" but I need the Octane one. To be completely frank the C4D one never worked for me in 15 years of using C4D.

Image

This is the one I need triggered via Python.

Image

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

PostPosted: Tue Dec 12, 2023 10:58 am
by SSmolak
Hurricane046 wrote:To be completely frank the C4D one never worked for me in 15 years of using C4D.


hmm yes it doesn't work. I never used it. Why you didn't reported this before to Maxon :)