2
$\begingroup$

Hi There Blender Peeps..

I am in need of some help, I am wanting to make a shortcut in the Item Properties to toggle a node from working,

The Item Properties shortcut I speak of is the area Right Side Bar of the VIEWPORT under ITEM -> Properties, and it is found in PROPERTIES Window -> Object Properties -> Custom Properties. It is here where you add these properties.

So to disable the node from working in my scene, which essentially improves playback performance from not having to playback the movie in the background...

I have found 3 ways to disable the movie from playing. I am wanting to do one of the following by using drivers and make the Item properties by the Custom property to be "0" or "1" which will Toggle the setting...

The 3 Ways I have found to disable the node from playing the movie.

1. Mute a Texture Node (Toggle it via the Item Properties Shortcut) I am unable to find anywhere a way to drive muting a node.?!

2. Toggle the "Auto Refresh Button" on the Texture Node. (When the Texture node is set to movie or Image Sequence) the Auto Refresh Button Appears.

3. Changing the frames count from 600 to 0, will also stop the movie playback, I know that if I can Drive this setting, I can make the expression var*600 (this would make the 0 = 0, and 1 = 600)

The Auto Refresh Button

Auto Refresh on the Texture Node (Movie Mode)

I have tried a Driver but it appears that the auto-refresh button drives the Item Properties Shortcut! (I want the Item properties Shortcut to Enable / Disable the Auto Refresh) Not the other way around!! Please ignore that offset is purple, this is a driver and working fine. I am wanting to make the auto-refresh button to be the item that is driven by the new. shortcut

The auto refresh button has a data path "node_tree.nodes["Image Texture"].image_user.use_auto_refresh"

The Item properties have a data path ["prop"]

This is the Item Properties Box

This is the Item Properties Box

This is the item properties section..

Here is the Driver

With Respects to the answer provided and using the script, Is it possible to have the Auto Refresh for that Node appear in the properties box seen here?

enter image description here

$\endgroup$
2
  • $\begingroup$ To mute a node the shortcut is M $\endgroup$ – susu Jan 6 at 2:58
  • 1
    $\begingroup$ My initial thought was just a MixRGB and toggle the factor. $\endgroup$ – Allen Simpson Jan 6 at 4:21
1
$\begingroup$

Seems like you are trying to use drivers where an add-on or a script would do the job. Here is a short example with a slightly modified version of the UI Panel Template shipped with blender. (In the text editor go to Templates > Python to find templates).

This will create a panel in the Object properties where you can acces the Auto Refresh field of your node when you select the correct object.

enter image description here

import bpy

# Make sure the image sequence node name (NOT label) matches this
image_texture_name = "Image Texture"
# Make sure your material name matches this
material_name = "Material"
# Make sure your object name matches this
object_name = "Plane"


class LayoutDemoPanel(bpy.types.Panel):
    """Creates a Panel in the scene context of the properties editor"""
    bl_label = "Image Sequence Quick access"
    bl_idname = "SCENE_TEST_PT_layout"
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "object"
    
    @classmethod
    def poll(cls, context):
        # Assert the selected object is the one containing the image sequence :
        return context.active_object.name == object_name

    def draw(self, context):
        layout = self.layout
        mat = bpy.data.materials.get(material_name)
        # Assert the material actually exists and contains nodes :
        if not mat or not mat.node_tree or not mat.node_tree.nodes:
            layout.label(text=f"Make sure a material name '{material_name}' exists")
            return
        nodes = mat.node_tree.nodes
        image_sequence = nodes.get(image_texture_name)
        
        # Assert the node exists and actually is an Image Texture node:
        if not image_sequence or not hasattr(image_sequence, "image_user"):
            layout.label(text=f"Make sure an Image Sequence node named '{image_texture_name}' exists")
            return

        # This line "copies" the "Auto Refresh" field from the texture into the newly created panel
        layout.prop(image_sequence.image_user, "use_auto_refresh")
        # Remove the # if you prefer toggling the "mute" property of the node :
        #layout.prop(image_sequence, "mute")


def register():
    bpy.utils.register_class(LayoutDemoPanel)


def unregister():
    bpy.utils.unregister_class(LayoutDemoPanel)


if __name__ == "__main__":
    register()

Click here to learn how to run a script

Result :

enter image description here

Problem is, you have to run this script everytime you close and open blender. But there are plenty of resources online and here on stack exchange to help you turn a script into a permanent add-on.

If you want the new panel to appear in the "N" panel of the 3D view, just replace the lines :

    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "object"

with

    bl_space_type = 'VIEW_3D'
    bl_region_type = 'UI'
    bl_category = "Item"

Result (you can reorder panels with the 8 dots on the right of the headers):

enter image description here

$\endgroup$
5
  • $\begingroup$ Your a Blender God. $\endgroup$ – ToxsickcitY Jan 6 at 9:58
  • $\begingroup$ Wow, nono, not at all :) , this is a simple panel, and if you have need of this kind of optimisations I suggest you look further into the subject, it is intimidating at first but quite powerful :) I forgot to add that you can modify the names of the object, material and node in the script in the first few lines, but you then have to make sure you also change it in your scene. cheers $\endgroup$ – Gorgious Jan 6 at 10:33
  • $\begingroup$ I got it to work, I am so happy to have the shortcut now, I edited the main question asking if that can be moved? $\endgroup$ – ToxsickcitY Jan 6 at 16:39
  • $\begingroup$ I updated the answer with info to show it in the 3D viewport besides custom props $\endgroup$ – Gorgious Jan 7 at 7:35
  • $\begingroup$ Thanks again for your help, $\endgroup$ – ToxsickcitY Jan 7 at 18:15
1
$\begingroup$

Those properties are not animatable. You can't add a driver to them. Although they can be used to drive other properties, as you noticed.

However as stated in the comments you can use a Mix RGB node and drive the factor field, to be 0 or 1 for True or False.

enter image description here

Use the first Fac to be driven by the Auto Refresh custom property, and the second Fac to be driven by the Mute property. I set it to black but you can also use a Mix shader with a transparent shader like so depending on what you want to achieve.

enter image description here

$\endgroup$
5
  • $\begingroup$ The problem I have here is that cpu usage remains high while playing back the scene. I need a way to disable it, or remove the link between say Texture and Mix node, this also stops the scene from playing the video. is there a way to brake the link via driver? $\endgroup$ – ToxsickcitY Jan 6 at 7:52
  • $\begingroup$ I have 2 Videos in the scene, and I want to interactively select the channel, but having blender playing back 2 videos slows the framerate considerably, these are high bitrate and Resolution. When the texture node is not auto updated, disabled or frame count to 0, blender runs fast again by having one video playing back, I am hoping to make this work with those drivers as changing the channel can essentially disable the other video as well $\endgroup$ – ToxsickcitY Jan 6 at 8:01
  • $\begingroup$ Is it possible to use a Driver to control which OUTPUT MATERIAL is enabled? I have found that having two exact node setups in the Material but with two Material Outputs. selecting one or the other, blender is fast! $\endgroup$ – ToxsickcitY Jan 6 at 8:04
  • $\begingroup$ Makes sense. I think you would have better luck with a very simple addon to expose this property in a panel or anywhere in the UI. Have you ever dabbled in python scripting in Blender ? $\endgroup$ – Gorgious Jan 6 at 8:05
  • $\begingroup$ I know about the scripts, but I am not able to code them, they are way too complex haha, do you know of any plugins which can do the sort of thing I need? $\endgroup$ – ToxsickcitY Jan 6 at 8:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.