==== Octane useful scripts ====

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

Moderator: aoktar

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

Postby ShivaMist » Wed Aug 23, 2023 11:42 am

ShivaMist Wed Aug 23, 2023 11:42 am
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
ShivaMist
Licensed Customer
Licensed Customer
 
Posts: 75
Joined: Thu Oct 11, 2018 5:07 pm
Location: Paris

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

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

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


Thank you very much. That's fantasitc !
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

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

Postby Hurricane046 » Wed Nov 22, 2023 11:52 am

Hurricane046 Wed Nov 22, 2023 11:52 am
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
2x RTX 2080 Ti | 2x RTX 2070 | 2x GTX 1080 Ti | 1x GTX 1080 | 1x GTX980 Ti
User avatar
Hurricane046
Licensed Customer
Licensed Customer
 
Posts: 78
Joined: Wed Jul 25, 2018 6:57 am

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

Postby Hurricane046 » Thu Nov 23, 2023 8:39 am

Hurricane046 Thu Nov 23, 2023 8:39 am
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()
2x RTX 2080 Ti | 2x RTX 2070 | 2x GTX 1080 Ti | 1x GTX 1080 | 1x GTX980 Ti
User avatar
Hurricane046
Licensed Customer
Licensed Customer
 
Posts: 78
Joined: Wed Jul 25, 2018 6:57 am

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

Postby Hurricane046 » Tue Dec 05, 2023 9:17 am

Hurricane046 Tue Dec 05, 2023 9:17 am
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
2x RTX 2080 Ti | 2x RTX 2070 | 2x GTX 1080 Ti | 1x GTX 1080 | 1x GTX980 Ti
User avatar
Hurricane046
Licensed Customer
Licensed Customer
 
Posts: 78
Joined: Wed Jul 25, 2018 6:57 am

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

Postby aoktar » Mon Dec 11, 2023 12:15 pm

aoktar Mon Dec 11, 2023 12:15 pm
[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
Attachments
a1.jpg
a1.jpg (20.6 KiB) Viewed 15211 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: 15970
Joined: Tue Mar 23, 2010 8:28 pm
Location: Türkiye

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

Postby Hurricane046 » Mon Dec 11, 2023 1:39 pm

Hurricane046 Mon Dec 11, 2023 1:39 pm
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. :?
2x RTX 2080 Ti | 2x RTX 2070 | 2x GTX 1080 Ti | 1x GTX 1080 | 1x GTX980 Ti
User avatar
Hurricane046
Licensed Customer
Licensed Customer
 
Posts: 78
Joined: Wed Jul 25, 2018 6:57 am

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

Postby SSmolak » Tue Dec 12, 2023 8:18 am

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


Shift+F12 type "unused" "duplicated" and you will have all commands listed here
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

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

Postby Hurricane046 » Tue Dec 12, 2023 8:58 am

Hurricane046 Tue Dec 12, 2023 8:58 am
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
2x RTX 2080 Ti | 2x RTX 2070 | 2x GTX 1080 Ti | 1x GTX 1080 | 1x GTX980 Ti
User avatar
Hurricane046
Licensed Customer
Licensed Customer
 
Posts: 78
Joined: Wed Jul 25, 2018 6:57 am

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

Postby SSmolak » Tue Dec 12, 2023 10:58 am

SSmolak Tue Dec 12, 2023 10:58 am
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 :)
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 10 guests

Sat Apr 27, 2024 6:14 pm [ UTC ]