0

I have tried changing the scene, but it doesn't seem to work. Am i missing something?

bpy.ops.object.select_all(action='DESELECT') #deselect all object

bpy.data.objects['inner.002'].select_set(True)

obj = bpy.context.window.scene.objects['inner.002']
bpy.context.view_layer.objects.active = obj

bpy.context.object.display_type = 'TEXTURED'

bpy.data.screens["Layout"].shading.show_xray = True
bpy.data.screens["Layout"].shading.type = 'WIREFRAME'
HikariTW
  • 7,821
  • 2
  • 18
  • 37
Michael Teiniker
  • 1,094
  • 1
  • 12
  • 26

1 Answers1

1

First start with the window, most people will only have one window open, but when there are multiple windows, each can show a different scene.

win = bpy.context.window_manager.windows[0]

In 2.80 the current scene is a window property.

win.scene = bpy.data.scenes['Scene.002']

In 2.7x the current scene is a property of the active screen layout -

win.screen.scene = bpy.data.scenes['Scene.001']

But then what your sample code is trying to do is change properties of a visible editor, which isn't changing the scene, you need to dig a bit more for these properties. The relevant properties have also changed in 2.80.

In 2.80 the 3D viewport shading options are within the shading property -

for area in win.screen.areas:
    if area.type == 'VIEW_3D':
        area.spaces[0].shading.type = 'WIREFRAME'
        area.spaces[0].shading.show_xray_wireframe = True
        area.spaces[0].shading.xray_alpha_wireframe = 0.5

In 2.7x we can set wireframe display as part of the 3D viewport properties, the equivalent to wireframe x-ray is occlude geometry, which is an edit mode feature.

for area in win.screen.areas:
    if area.type == 'VIEW_3D':
        area.spaces[0].viewport_shade = 'WIREFRAME'
        area.spaces[0].use_occlude_geometry = False
sambler
  • 55,387
  • 3
  • 59
  • 192