Useful xray lasso script broken by 3.2

I have used this amazing script for ~5 years. It basically toggles on xray mode everytime I go to lasso select something. When I upgraded to 3.2 it broke. I’m not sure what broke as the code looks clean to me. There’s a piece of the code below.

I’ve read that they changed ‘MOUSEMOVE’ to have an event value of ‘NOTHING’ instead of ‘PRESS/RELEASE’


And I know that those things are used in the script, but I’m still not sure what to change as I’m pretty green at this.

Does anyone know how to help?

class HP_OT_select_through_lasso(bpy.types.Operator):
	bl_idname = "view3d.select_through_lasso"
	bl_label = "Select Through Lasso"

	def modal(self, context, event):
		bpy.context.space_data.shading.show_xray = True
		if event.type == 'MOUSEMOVE' and event.value == 'PRESS':
			bpy.ops.view3d.select_lasso('INVOKE_DEFAULT',mode='SET')
			return {'RUNNING_MODAL'}
		if event.type in {'RIGHTMOUSE', 'ESC'}:  # Cancel
			bpy.context.space_data.shading.show_xray = False
			return {'CANCELLED'}
		elif event.type == 'MOUSEMOVE' and event.value == 'RELEASE':
			bpy.context.space_data.shading.show_xray = False
			return {'CANCELLED'}
		return {'RUNNING_MODAL'}
	def invoke(self, context, event):
		if bpy.context.space_data.shading.show_xray == True:
			bpy.ops.view3d.select_lasso('INVOKE_DEFAULT',mode='SET')
		else:
			context.window_manager.modal_handler_add(self)
		return {'RUNNING_MODAL'}

Try this one:

class HP_OT_select_through_lasso(bpy.types.Operator):
	bl_idname = "view3d.select_through_lasso"
	bl_label = "Select Through Lasso"
        
	def modal(self, context, event):
		context.space_data.shading.show_xray = False
		return {'CANCELLED'}

	def invoke(self, context, event):
		context.space_data.shading.show_xray = True
		context.window_manager.modal_handler_add(self)
		bpy.ops.view3d.select_lasso('INVOKE_DEFAULT', mode='SET')
		return {'RUNNING_MODAL'}
2 Likes

This works thank you!

Which xray addon is it?

It’s heavypoly’s lasso select through

X-Ray lasso select through seems to be broken again in 3.4. Haven’t tried 3.5 yet. I used this solution to get it to work in 3.2 but as I said it stopped working again. Is it possible to fix it again pls?

without seeing an error message it will be difficult to help.

Tested on 3.4.1 and 3.5.0 beta. The operator works fine here.

Sorry, my bad. I’m using a portable version and I keep forgetting to move that one file between versions.

1 Like