Can I bind other parameters to markers than the active scene cam

I am working on an animatic and I would like to have some of my 3d objects change loc/r/s when a certain camera is marker activated. Is there a way to do this with drivers or something?

If you think about this slightly differently, you can very easily get the Scene.camera in Blender Python, which will give you the active camera, and then tie your object transforms to that.

if bpy.data.scenes[“Scene”].camera.name = “Camera.001”:
    object.location.x = 1

That’s pseudo-code but it should work :slight_smile:

1 Like

great, thanks. that should get me somehwere :slight_smile:
I’ll close this as solved once I arrived… (still getting my feet wet with scripting in blender :stuck_out_tongue: )

I’ll shoot you some actually functional code later today, if you want :slight_smile:

wow, that would be super nice. Don’t waste too much of your time on it, though…
but yeah: blender community = awesome :upside_down_face:

Here you go, wasn’t too hard :slight_smile:

import bpy
import math
from bpy.app.handlers import persistent

@persistent
def fake_bind(dummy):
    cameras = ["View_Camera","View_Camera.001"]
    active_camera = bpy.data.scenes["Scene"].camera.name
    obj = bpy.context.scene.objects["Cube"]

    if active_camera == cameras[0]:
        obj.location.z = 1
        obj.rotation_euler[0] = math.radians(60)
        obj.scale.y = .5
        
    else:
        obj.location.z = 0
        obj.rotation_euler[0] = math.radians(0)
        obj.scale.y = 2
    
bpy.app.handlers.depsgraph_update_post.append(fake_bind)  

I added location, rotation, and scale so you can see how each of those work. Note that rotation_euler uses [0], [1], or [2] for axes, and you need to convert degrees to radians.

You can paste this in the Text Editor, click Run, and (if you have two cameras and a cube), you can see it working :slight_smile:

You can change the obj parameter to whatever object you want, of course, and you could even have several objects affected in a list:

objects = [bpy.context.scene.objects["Cube"], bpy.context.scene.objects["Plane"]]
...
if active_camera == cameras[0]:
    objects[0].location.x = 10
    objects[1].location.y = -5
2 Likes

thank you so much, man! When I have finalized my system, I’ll post a blend file. I made a fine little GN instancer to switch between objects/collections so I don’t have to deal with animating render visibility (which sucks ass :frowning: ). If I can somehow link cameras to show/hide certain objects or collections, that would be such a lifesaver.

1 Like

Oh yeah for sure I gotchu :slight_smile:

Absolutely doable. Give me a bit, I’ll tackle that in between work projects today

1 Like

haha, thanks again, but I think I can handle it from here on :smiley: If I get stuck I know where to ask.
have a great day ~

1 Like

Hi. I’m trying to imagine what “depsgraph” is an abbreviation of…

What is a “depsgraph” ?

Thanks!

It’s the dependency graph- https://wiki.blender.org/wiki/Source/Depsgraph

depthgraph does seem to struggle a bit. It only updates when changing selections. but it it’s still a big upgrade

They say you should learn something new every day…? Well, I just did.

Thanks.

1 Like

It updates whenever you switch active camera, so if you have two sets of parameters bound to two cameras and you switch the active camera, the parameters will follow :slight_smile:

It also updates whenever any mesh is changed, when you toggle between any modes, when you use any operator, when you add any data, you edit any data, delete any data, move between keyframes, etc. It’s hugely versatile, and it’ s about the best you can get without having a real-time update loop (that would freeze Blender)

yep. It’s awesome :smiley: I am already constraining my cams to everything. I was just talking about the viewport not updating when the camera is automatically switched by a bound marker. but its just the VP anyways, rendering is fine.

Oh gotcha. The viewport will update if you’re in camera view, at least, that might help :slight_smile:

can’t reproduce it here. could be the alpha version though. I’ve had some quirks in the last builds. Maybe one day markers can be bound to other stuff than active scene cam.

That could be it… it works perfectly on 3.01… this may sound stupid, but did you “run” the script after pasting it in?

yes. but it doesn’t update, even when I press the script play button.
tried it with 3.01, 3.1, 3.2

this is how it behaves on my end. forgot to record mouse cursor, sorry

weird… maybe it is a windows issue. I’ll try on linux later (I disabled all my addons, reset to factory default too)

I’m using windows, so it shouldn’t be an OS thing :thinking: this is… really weird. I have no idea what’s going on here