Page MenuHome

python .scene_raycast returned object is not selectable
Closed, ResolvedPublic

Description

System Information
Linux Mint 19 Nvidia 1070

Blender Version
Broken: 2.8
Worked: 2.79

Short description of error
python .scene_raycast returned object is not selectable

Exact steps for others to reproduce the error
Perform a scene ray cast and then use a .select_set(action='SELECT') on returned object.
RuntimeError: Error: Object 'Cube' not in View Layer 'RenderLayer'!

Load startup file, then run this into blender's console.

context = C
orig = Vector((10,10,10))
vec = -orig

res, pos, normal, face_index, obj, matrix_world = context.scene.ray_cast(
            view_layer=context.view_layer,
            origin=orig,
            direction=vec)

obj.select_set(action='SELECT')

Event Timeline

Bastien Montagne (mont29) claimed this task.

No bug here, error message is self-explanatory really. Just how new 2.8 system works.

Checked again with factory startup file.

throws RuntimeError: Error: Object 'Cube' not in View Layer 'View Layer'!

but Cube is on 'View Layer' !

>>> C.view_layer.objects[:]
[bpy.data.objects['Cube'], bpy.data.objects['Lamp'], bpy.data.objects['Camera']]
>>> C.view_layer.name
'View Layer'

So i feel there is realy something going wrong here.

Bastien Montagne (mont29) lowered the priority of this task from Needs Triage by Developer to Confirmed, Medium.

Eeek, yes indeed, actually it returns evaluated version of the object (COW, you know…), not the 'real' data from bpy.data… will fix.