Synchronize Workspaces - Blender Add-on

Well try to test it like that:
C.workspace.screens[0].areas[3].spaces[0].local_view is not None

The problem is not that. You need to get objects thatā€™s are in local view, but object.local_view_get always returns False
https://blender.stackexchange.com/questions/251743/how-to-get-a-list-of-objects-thats-currently-in-local-view

Oh ok. Yes I misunderstood your problem

@Crantisz:

import bpy
for area in bpy.context.screen.areas:
    for space in area.spaces:
        if space.type == 'VIEW_3D' and space.local_view is not None:
            for obj in bpy.context.scene.objects:
                print("Obj",obj.name,obj.local_view_get(space), obj.visible_get(viewport=space))

You could check visible_get then disable local view, check again and compare the results.

Itā€™s very close! If I hide an object in local view, it will be removed in local view on the iteration, but overall looks good.

1 Like

So, thanks for @Debuk Iā€™ve added local view support, not ideal, but it looks that it works. Grab 1.6 version for that.

Iā€™ve added shading mode and shading settings synchronization support as separate toggles:

image

Grab 1.7 version to get this

4 Likes

Perfect itā€™s working!

Hope you will make another implementation with local view when the bug will be fixed.
Because it has some issue when you switch workspace first time in session.

And what is that issue?

Example:
when you go to local view and then select only one object


after you switch to workspace where you were already, it starts to work fine.

1 Like

Maybe it is related to edit modeā€¦

Well it happens here too and in object mode

  • Open Blender
  • Keep the cube
  • Add monkey
  • Add Torus
  • Select Monkey and Torus
  • LocalView
  • Select Torus
  • Switch Workspace

ā†’ then there is only the Torus left visivble instead of both

1 Like

Iā€™ve made a little video about add-on:

5 Likes

Great video. Simple and straightforward. Exactly what is needed!

Had a look at your code and the problem is that the selection you do in your code isnt used.
I added a viewlayer update.
Works now.

        for obj in objects:
            obj.select_set(True)
        bpy.context.view_layer.update()

Might be needed again further down, havent checked that.

One last thing I did is a rewrite of the the setview. Couldnā€™t resist.
If you want to use it, replace everything after the context override definition with this.

vrot= rotation.to_euler()
import mathutils

backVec = mathutils.Vector((0.0, 0.0, -1.0))
backVec.rotate(vrot)

rightVec = mathutils.Vector((1.0, 0.0, 0.0))
rightVec.rotate(vrot)

axis = "FRONT"
if backVec.y == 1: axis= "FRONT"
if backVec.y == -1: axis = "BACK"
if backVec.x == 1: axis = "LEFT"
if backVec.x == -1: axis = "RIGHT"
if backVec.z == 1: axis ="BOTTOM"
if backVec.z == -1: axis ="TOP"
# RIGHTVEC:
#  x:1 => TOP Def ; y:-1 => TOP90 x:-1 => TOP180 y:1 => TOP-90
#  x:1 => Bottom Def y:1 => Bottom90 x:-1 => Bottom180 y:-1 => Bottom-90

bpy.ops.view3d.view_axis(context, type=axis)

Notes:
The import shouldnt stay there.
I wanted to look up how to set the roll, but am running out of time here.

Nice solution, much easier. I canā€™t find how to set up 90deg 180deg -90deg views, though. And never relay on float :slight_smile: But anyway, thanks. Iā€™ve added it to 1.8 version.

Also, support of overlays and more viewport settings (like local camera) has been added. Overlays have a separate toggle:

image

Grab 1.8 version and test!

1 Like

You can allow an epsilon if you want.

:+1:

But lock to 3D cursor works not good, an offset is added. I havenā€™t found how to fix that.

Maybe I can have a look later. But i found bpy.ops.view3d.view_roll, havent tested it though.