Last active
December 17, 2015 16:49
-
-
Save fsiddi/5641899 to your computer and use it in GitHub Desktop.
Simple script that makes a button to sync multiview setting across scenes in Blender
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
def SyncViews(): | |
for view in bpy.context.scene.render.views: | |
if (view.name == 'left'): | |
use_left = view.use | |
camera_left = view.camera | |
if (view.name == 'right'): | |
use_right = view.use | |
camera_right = view.camera | |
for scene in bpy.data.scenes: | |
if scene != current_scene: | |
for view in scene.render.views: | |
if (view.name == 'left'): | |
view.use = use_left | |
view.camera = camera_left | |
if (view.name == 'right'): | |
view.use = use_right | |
view.camera = camera_right | |
class SyncViewsPanel(bpy.types.Panel): | |
bl_label = "Sync Views" | |
bl_idname = "VIEWS_PT_sync_views" | |
bl_space_type = 'PROPERTIES' | |
bl_region_type = 'WINDOW' | |
bl_context = "render_view" | |
def draw(self, context): | |
layout = self.layout | |
row = layout.row(align=True) | |
row.operator("sync_views.sync", | |
text="Sync", icon='FILE_REFRESH') | |
class SyncViewsOperator(bpy.types.Operator): | |
bl_idname = "sync_views.sync" | |
bl_label = "Operatorews operator" | |
bl_description = "Syncs.syncs across scenes" | |
def execute(self, context): | |
SyncViews() | |
return {'FINISHED'} | |
def register(): | |
bpy.utils.register_class(SyncViewsPanel) | |
bpy.utils.register_class(SyncViewsOperator) | |
def unregister(): | |
bpy.utils.unregister_class(SyncViewsPanel) | |
bpy.utils.unregister_class(SyncViewsOperators) | |
if __name__ == "__main__": | |
register() |
One question: do you think this should become an actual C operator? I can make it better of course (to support any camera name, the new render labels, ect), but if this gets implemented natively maybe it's not needed?
hm what do you think? I think it doesn't hurt to have this there. The advantage of python is that you can sync the scene for the lib linked scenes as well (yeah a hack, but python addons can have hacks, C shouldn't). In C we would need to go over the other scenes and if one of the lib linked scenes has a different status all we can do is to report a "warning".
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
yup, that's what I understood from your idea.
You may need to link the camera to the new scene in case it is not ...
(something to try)