0
$\begingroup$

enter image description here

I would like to make one of my objects transparent in the 3D Viewport. When I look around I get tons of answers - all different, and some of them a lot more complicated than others and also older from versions of Blender. I can't get any of them to work. I just want the simplest way to make anything transparent; like descreasing the alpha channel or checking an x-ray parameter or something like that. Any ideas?

I tried bpy.context.active_object.show_transparent=True but I'm sure what it does, but it seems like what I want.

Here are some of the links I found:

$\endgroup$
8
  • 2
    $\begingroup$ Might be a good idea to add some reference images of what you call "transparent" and the links to the answers that weren't helpful... $\endgroup$
    – brockmann
    Dec 8, 2020 at 13:42
  • $\begingroup$ You are talking about the solid view, not material preview or rendering, right ? $\endgroup$
    – Gorgious
    Dec 8, 2020 at 14:57
  • 1
    $\begingroup$ Better! Related: Code to toggle viewport display material alpha I'd recommend do what ever you want to to in the GUI first, then find a way doing it with python. $\endgroup$
    – brockmann
    Dec 8, 2020 at 19:44
  • $\begingroup$ but you also have to set viewport shading to "object" (@brockmann) $\endgroup$
    – lemon
    Dec 8, 2020 at 19:48
  • 1
    $\begingroup$ Eurika! I have an image so that I can answer my own question. $\endgroup$
    – DrDress
    Dec 8, 2020 at 19:49

1 Answer 1

2
$\begingroup$

One option is to set the alpha value (fourth component) of Material.diffuse_color:

float array of 4 items in [0, inf], default (0.8, 0.8, 0.8, 0.8)

import bpy

# Get the object in context
obj = bpy.context.object

# Get the active material
mat = obj.active_material

# Set the alpha value of the diffuse color
mat.diffuse_color = (0.0 , 0.0 , 1.0 , 0.7)

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.