Shading for Inactive objects in viewport (wireframe)

Hello,

There is a little addon that we created with collaboration of people from this topic

many Big thanks to them! (@MACHIN3, @ckohl_art)

What addon does
It make all inactive objects look wireframe


Inactive_Shading_v_1_0_3.py (4.0 KB)

Feel free to modify for your best usability or make improvement.
And just in case, I’m not a coder, but only a person who proposed an idea. =)

=====================================================
Ver 1.0.4
With toggling Wire and Bounds. If one is active, other is shaded (Thanks to @ckohl_art)
Inactive_Shading_v_1_0_4.py (5.5 KB)

20 Likes

Nice. I didn’t feel like looking up how to do a checkbox. :stuck_out_tongue:

2 Likes

The very usefull thing. Thanks

@APEC Thank you for creating this script, its super useful!!

1 Like

I just realized that if we’re temporarily disabling the addon or completely uninstalling the addon it should probably clean up after itself and revert the objects back to textured. Otherwise everything that isn’t selected will stay wireframe unless the user manually changes them back.

Something like this should go somehwere in the unregister() def:

    for obj in bpy.context.visible_objects:
        obj.display_type = 'TEXTURED'

Although there’s no way to know if the user intentionally wants some objects to be ‘WIRE’… or what to do with objects that aren’t visible? Impossible to know what the user wants. We could just set EVERY object back to textured instead of only the visible_objects.

And is it just me or does the inactive_shading prop still exist after uninstalling the addon?

inactive

Oh, and the GPL block should go up at the top.

1 Like

Feel free to experiment with script.
About GPL block we can use standard

# ##### BEGIN GPL LICENSE BLOCK #####
#
#  This program is free software; you can redistribute it and/or
#  modify it under the terms of the GNU General Public License
#  as published by the Free Software Foundation; either version 2
#  of the License, or (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software Foundation,
#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
#  or see <http://www.gnu.org/licenses/>.
#
# ##### END GPL LICENSE BLOCK #####

or file
LICENSE (34.3 KB)
I think this is the correct text and file.

About inactive_shading prop after uninstalling the addon
I got this


no “inactive_shading” or even “inact” in search result…
even more, I have no this even if addon is installed (sorry for “even” pun)
Or where it should be?
And I agree that after uninstalling it should turn all objects back to TEXTURED.

Is there anyway, say ive toggled the addon on, now im viewing my active object in solid mode, non active in wireframe, can i have the nonactive in colored in random mode so i can distinguish the various objects via there colors in the viewport while im working on my solid shaded object? hope that makes sense.

I think it possible in Wireframe shading viewport only…

cant even manually change color to wireframe in Solid viewport…
Or maybe some one can confirm it’s doable by python?

Maybe someone will come up with a workaround. Would be helpful. Thanks mate.

I Made a slight update.
When disabling addon, all objects become TEXTURED instead of WIRE inactive.
Inactive_Shading_v_1_0_3.py (4.0 KB)
First post updated.

2 Likes

Setting per-object wireframe color (even random) while staying in any view mode other than wireframe appears to be impossible with the provided Blender functions. https://docs.blender.org/api/current/bpy.types.Object.html

You can either set the viewport shading mode to wire, in which case you get access to random wire color or manual object wire color, or you get shaded mode. It’s either/or due to a Blender design choice. There’s a rejected patch for per-object wire colors. https://developer.blender.org/T33817

It might be doable if someone gets the mesh data, hides the object, and draws the wire object themselves directly with opengl but that would be… hacky… and would probably have undesired side effects (like not showing up in renders) because the objects would actually be in the hidden state (not to mention possible performance issues with drawing all the objects yourself instead of letting the viewport renderer handle it).

1 Like

Great addon. Option to Bounds will be usefull to i think

Hello,

if you need it as soon as possible, you can just change WIRE to BOUNDS in a text editor, there are only 3 of them in the code.

For adding additional button I think it need to rewrite a lot of code, cos it need to make choose option between Wire, Bounds and default Textured, two checkboxes not the option.
Maybe if some python guru could help, my skills allow only to write simple code =)

1 Like

It works. Thanks!

Give this a try:
Inactive_Shading_v_1_0_4.py (5.5 KB)

2 Likes

Nice!
Thanks!
In my taste it could be like this one


P.S. and to be right, we need to add MACHIN3 to the authors too

Summary

UPD:
I think it can be possible with EnumProperty

# Get Inactive Shading Style
def update_inactive_shading_style(self, context):
    if self.select_inactive_shading_style == 'TEXTURED':
        inactive_textured_shading()        
    elif self.select_inactive_shading_style == 'WIRE':
        inactive_wire_shading()
    elif self.select_inactive_shading_style == 'BOUNDS':
        inactive_bounds_shading()
    elif self.select_inactive_shading_style == 'SOLID':
        inactive_solid_shading()

and in register

def register():
    bpy.types.Scene.select_inactive_shading_style = bpy.props.EnumProperty(
                            items=[
                            ("TEXTURED", "Textured", "TEXTURED", 1), 
                            ("WIRE", "Wire", "WIRE", 2),
                            ("BOUNDS", "Bounds", "BOUNDS", 3),
                            ("SOLID", "Solid", "SOLID", 4)
                            ], 
                            name="IS Style", 
                            description="Selected inactive shading style", 
                            update=update_inactive_shading_style,
                            )

and draw buttons

def PanelInactiveShading(self, context):
    layout = self.layout
    layout.separator()
    layout.label(text="Inactive Objects Shading")
    row = layout.row()
    row.prop(context.scene, "select_inactive_shading_style", expand=True)

something similar to this…
it remains only to correctly define the functions …

2 Likes

in fact, the checkbox is the right choice because you need to completely disable this feature to prevent confusing if some objects need to be in different styles.
I also add MACHIN3 to the authors and update first post.

Hi, great addon But It has a major drawback too which can be OR Else has to be Fixed which is Inactive Shading Addon should not consider manupulating the shading of Boolean Objects. SO if I am using this addon, the Bool OBjects { the cutters} which are auto set to wireframe by blender default addon Bool Tool which is of course a necessity is killed by this addon :wink:, So I request a feature update. I hope I was able to explain nicely :blush:

Hello.
It’s a bit old and simple script not designed for complex scenes.
It need to be completely rewrite to take into account objects.display_type, list all mesh objects in the scene and store display type if it different from ‘TEXTURED’ and restore them after unchecking checkbox.
Maybe here can be more elegant solution.

UPD:
starting point.

solid_objects = []
wire_objects = []
bounds_objects = []
for ob in bpy.data.objects:
    if ob.type == 'MESH' and ob.display_type == 'SOLID':
        solid_objects.append(ob)
    if ob.type == 'MESH' and ob.display_type == 'WIRE':
        wire_objects.append(ob)
    if ob.type == 'MESH' and ob.display_type == 'BOUNDS':
        bounds_objects.append(ob)

print(solid_objects)
print(wire_objects)
print(bounds_objects)
1 Like

This will 100% ignore any mesh that is being used as a cutter:
Inactive_Shading_v_1_0_5.py (6.5 KB)

Is it just me or is there an extreme performance hit when changing the Viewport Display mode of any object that has a boolean modifier with the “Exact” solver?

Edit: Apparently the performance hit is only when all 3 of these conditions are true:

  • boolean modifier is using a Collection as its cutter source
  • and
  • the collection has more than 1 mesh in it
  • and
  • boolean solver type is “Exact”

image

Tested on Blender 2.93.0 on Windows 10

1 Like