Page 2 of 3

Re: Reload all textures in Octane for Cinema 4D

Posted: Sun Oct 28, 2018 4:45 pm
by aoktar
Here's a quick script I made now. It's forcing the reloading the ImageTextures in selected material.

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: Reload all textures in Octane for Cinema 4D

Posted: Sun Oct 28, 2018 4:50 pm
by omardex
aoktar wrote:Here's a quick script I made now. It's forcing the reloading the ImageTextures in selected material.

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()

Works Aoktar, Thanks!

Re: Reload all textures in Octane for Cinema 4D

Posted: Sun Oct 28, 2018 4:55 pm
by omardex
@Ferdinand13 here is a script file (check the link), put it in your *:/program files/maxon/c4d/library/scripts folder


https://we.tl/t-aV5RNBDslU

Re: Reload all textures in Octane for Cinema 4D

Posted: Sun Oct 28, 2018 5:04 pm
by Ferdinand13
OMG Omar! That works like a charm. Thanks a lot! And thanks a lot for providing the code Aoktar. This is really going to help speed things up.

You made my weekend! :D

Re: Reload all textures in Octane for Cinema 4D

Posted: Sun Oct 28, 2018 5:06 pm
by aoktar
Ferdinand13 wrote:OMG Omar! That works like a charm. Thanks a lot! And thanks a lot for providing the code Aoktar. This is really going to help speed things up.

You made my weekend! :D
Lucky that I had some time to do :) Enjoy it! I've put it to C4D/HelpSupport section.

Re: Reload all textures in Octane for Cinema 4D

Posted: Sun Oct 28, 2018 5:06 pm
by omardex
Ferdinand13 wrote:OMG Omar! That works like a charm. Thanks a lot! And thanks a lot for providing the code Aoktar. This is really going to help speed things up.

You made my weekend! :D
Thanks to Aoktar, he must be a busy guy, I'm the middle man I didn't do big thing.

Re: Reload all textures in Octane for Cinema 4D

Posted: Sun Oct 28, 2018 5:07 pm
by Ferdinand13
aoktar wrote:
Ferdinand13 wrote:OMG Omar! That works like a charm. Thanks a lot! And thanks a lot for providing the code Aoktar. This is really going to help speed things up.

You made my weekend! :D
Lucky that I had some time to do :) Enjoy it! I've put it to C4D/HelpSupport section.
Yes, thanks a lot. I know how busy you are. There isn't much I can offer in return, but if you want me to design a C4D compliant button for that function, let me know.

Re: Reload all textures in Octane for Cinema 4D

Posted: Sun Oct 28, 2018 7:17 pm
by Ferdinand13
I know, nobody asked for it, but just in case you need an icon to go with this amazing script ;)
Octane_ReloadTextures.png
Octane_ReloadTextures.png (14.34 KiB) Viewed 3032 times

Re: Reload all textures in Octane for Cinema 4D

Posted: Sun Oct 28, 2018 7:41 pm
by aoktar
Ferdinand13 wrote:I know, nobody asked for it, but just in case you need an icon to go with this amazing script ;)
Octane_ReloadTextures.png
Thanks for that!

Re: Reload all textures in Octane for Cinema 4D

Posted: Mon Oct 29, 2018 11:31 am
by Ferdinand13
You're most welcome!

BTW, I had some issues getting the custom icon to work within C4D, but the kind folks over at C4D Cafe helped me. In order for it to show up properly, you have to use a TIFF file, name the image file exactly the same as the script file and put them both into C4D's 'scripts' folder. Then it should be working.

Here's the icon as a TIFF, just in case.