# How to disable x-ray for annotations (grease pencil) in 2.8?

Is it even possible in 2.8? In 2.7 we had such ability, but now, when grease pencil and annotations are separate things, xray possible disable only for grease pencil, but not for annotations

## 2 Answers

This can be done with annotations programmatically. To my knowledge there's nowhere currently in the front end UI to do this for annotations though. Copy this line, go to the Scripting workspace, paste this in the console (place where you see >>) and press Enter.

bpy.data.grease_pencils['Annotations'].layers[0].show_in_front = False


Or this to change all existing annotation layers.

for layer in bpy.data.grease_pencils['Annotations'].layers: layer.show_in_front=False


I'm not sure why this was not kept accessible in the default UI for annotations. If it is somewhere (as of Blender 2.82), please someone let me know where. A fix for right now would be to paste in and run the code (after opening a new blank file) then go to File > Defaults > Save Startup File. You would have to run the code though for every new annotation layer you create, so maybe make a few dedicated layers and name them "non see-through" or something for when you want to use annotations that aren't see through.

Even if this option never returns to the default UI, would be pretty easy to create an addon that handles this. This will definitely be an option in the next version of Sensei Format.

• I tried doing this code, but it didn't work. It gave me an error: Traceback (most recent call last): File "<blender_console>", line 1, in <module> KeyError: 'bpy_prop_collection[key]: key "Annotations" not found' – RBlong2us Apr 8 at 19:55

@RBlongus2us You must use single or double quotation marks: "Annotations" or 'Annotations'. "Annotations" as well as "True" and "False" have to be written with a capital first letter (but not the entire word!) so that Blender and Python can recognize it:

The annotation layers are numbered beginning with "0" at the bottom of the layer list. This index is used in the square brackets, so that you for example switch off the x-ray visibility of the first and the fourth grease pencil layer (indices "0" and "3") in the last two images above with the commands:

bpy.data.grease_pencils['Annotations'].layers[0].show_in_front = False

bpy.data.grease_pencils['Annotations'].layers[3].show_in_front = False

'Annotations' is the name of your annotation data block. As long as you don't manually edit the name, the next annotation data block created would have the name 'Annotation.001' and the corresponding python command for switching it's first layer's x-ray display off would be:

bpy.data.grease_pencils['Annotations.001'].layers[0].show_in_front = False