Reload all textures in Octane for Cinema 4D

Maxon Cinema 4D (Export script developed by abstrax, Integrated Plugin developed by aoktar)

Moderators: ChrisHekman, aoktar

User avatar
aoktar
Octane Plugin Developer
Posts: 16066
Joined: Tue Mar 23, 2010 8:28 pm
Location: Türkiye
Contact:

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()
Octane For Cinema 4D developer / 3d generalist

3930k / 16gb / 780ti + 1070/1080 / psu 1600w / numerous hw
User avatar
omardex
Licensed Customer
Posts: 75
Joined: Wed Oct 21, 2015 4:45 pm
Location: Venezuela
Contact:

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!
Omar Tavera
Awesome Generalist

omardex.artstation.com

Octane render for c4d but moving more toward standalone with one 980ti
User avatar
omardex
Licensed Customer
Posts: 75
Joined: Wed Oct 21, 2015 4:45 pm
Location: Venezuela
Contact:

@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
Omar Tavera
Awesome Generalist

omardex.artstation.com

Octane render for c4d but moving more toward standalone with one 980ti
User avatar
Ferdinand13
Licensed Customer
Posts: 154
Joined: Sun Apr 03, 2016 4:21 pm
Location: United Kingdom

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
Custom PC, Intel Core i7-6800K, 48GB RAM, 3x MSI GeForce RTX 2080 Super Seahawk EK, Windows 10
Razer Blade Pro 17, Intel Core i7-10875H, 32GB RAM, 1x NVIDIA GeForce RTX 3080, 1x EVGA GeForce GTX 1080 Ti Hybrid (eGPU), Windows 10
User avatar
aoktar
Octane Plugin Developer
Posts: 16066
Joined: Tue Mar 23, 2010 8:28 pm
Location: Türkiye
Contact:

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.
Octane For Cinema 4D developer / 3d generalist

3930k / 16gb / 780ti + 1070/1080 / psu 1600w / numerous hw
User avatar
omardex
Licensed Customer
Posts: 75
Joined: Wed Oct 21, 2015 4:45 pm
Location: Venezuela
Contact:

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.
Omar Tavera
Awesome Generalist

omardex.artstation.com

Octane render for c4d but moving more toward standalone with one 980ti
User avatar
Ferdinand13
Licensed Customer
Posts: 154
Joined: Sun Apr 03, 2016 4:21 pm
Location: United Kingdom

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.
Custom PC, Intel Core i7-6800K, 48GB RAM, 3x MSI GeForce RTX 2080 Super Seahawk EK, Windows 10
Razer Blade Pro 17, Intel Core i7-10875H, 32GB RAM, 1x NVIDIA GeForce RTX 3080, 1x EVGA GeForce GTX 1080 Ti Hybrid (eGPU), Windows 10
User avatar
Ferdinand13
Licensed Customer
Posts: 154
Joined: Sun Apr 03, 2016 4:21 pm
Location: United Kingdom

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 3026 times
Custom PC, Intel Core i7-6800K, 48GB RAM, 3x MSI GeForce RTX 2080 Super Seahawk EK, Windows 10
Razer Blade Pro 17, Intel Core i7-10875H, 32GB RAM, 1x NVIDIA GeForce RTX 3080, 1x EVGA GeForce GTX 1080 Ti Hybrid (eGPU), Windows 10
User avatar
aoktar
Octane Plugin Developer
Posts: 16066
Joined: Tue Mar 23, 2010 8:28 pm
Location: Türkiye
Contact:

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!
Octane For Cinema 4D developer / 3d generalist

3930k / 16gb / 780ti + 1070/1080 / psu 1600w / numerous hw
User avatar
Ferdinand13
Licensed Customer
Posts: 154
Joined: Sun Apr 03, 2016 4:21 pm
Location: United Kingdom

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.
Attachments
Octane_ReloadTextures.tif
Octane_ReloadTextures.tif (58.04 KiB) Viewed 3014 times
Custom PC, Intel Core i7-6800K, 48GB RAM, 3x MSI GeForce RTX 2080 Super Seahawk EK, Windows 10
Razer Blade Pro 17, Intel Core i7-10875H, 32GB RAM, 1x NVIDIA GeForce RTX 3080, 1x EVGA GeForce GTX 1080 Ti Hybrid (eGPU), Windows 10
Post Reply

Return to “Maxon Cinema 4D”