I was wondering if I can add random viewport colors for better visibility like the new feature added in 2.8, but in 2.79 (maybe an add-on) since my PC doesn't support 2.8 due to my hardware limitations. I know that I can add materials to individual objects and change their viewport colours manually, but it's too much of work and unfeasible for large scenes. Thanks.


The following add-on randomizes the viewport color. It works for both Cycles and Blender Internal. Save the file into 2.79\scripts\addons and activate if through the preferences. The add-on creates panel in the 3D View properties (N) titled Randomize Viewport Color.

enter image description here enter image description here

In order for the viewport material to be applied for Cycles you need to have a material applied that uses nodes. This is a safety feature, because otherwise changing the viewport color would also change the material color. A limitation for Cycles in 2.79b is that the viewport color is tied to the material. Every object with the same material will have the same color.

Please keep in mind that this is a quickly written add-on and may have some areas that could be improved.

bl_info = {
    "name": "Randomize Viewport Colors",
    "author": "Robert Guetzkow",
    "version": (1, 0),
    "blender": (2, 79, 0),
    "location": "View3D > Properties",
    "description": "Randomizes the viewport colors of all objects",
    "warning": "",
    "wiki_url": "",
    "category": "3D View",

import bpy
import random

class RandomColorSettings(bpy.types.PropertyGroup):
    use_viewport_color = bpy.props.BoolProperty(
        name="Enable Viewport Color",
        description="When checked and update is pressed the viewport coloring will be enabled for all materials.",

class OBJECT_OT_update(bpy.types.Operator):
    bl_idname = "randomize_viewport_colors.update"
    bl_label = "Update"
    bl_options = {'REGISTER', 'UNDO'}

    def execute(self, context):
        if context.scene.render.engine == "CYCLES":
            for mat in bpy.data.materials:
                # Make sure that nodes are used, otherwise this will change the actual material color
                if mat.use_nodes:
                    if context.scene.use_viewport_color:
                        mat.diffuse_color = (random.uniform(0.0, 1.0),
                                             random.uniform(0.0, 1.0),
                                             random.uniform(0.0, 1.0))
                        mat.diffuse_color = (1.0, 1.0, 1.0)
            for obj in bpy.data.objects:
                obj.color = (random.uniform(0.0, 1.0), random.uniform(0.0, 1.0), random.uniform(0.0, 1.0), 1.0)

            for mat in bpy.data.materials:
                mat.use_object_color = context.scene.use_viewport_color

        return {'FINISHED'}

class VIEW3D_PT_randomize_viewport_colors(bpy.types.Panel):
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'UI'
    bl_label = "Randomize Viewport Colors"

    def draw(self, context):
        layout = self.layout
        layout.prop(context.scene, "use_viewport_color")

classes = (

def register():
    for cls in classes:
    bpy.types.Scene.use_viewport_color = bpy.props.BoolProperty(
        name="Enable Viewport Color",
        description="When checked and update is pressed the viewport coloring will be enabled for all materials.",

def unregister():
    for cls in classes:
    del bpy.types.Scene.use_viewport_color

if __name__ == "__main__":
  • $\begingroup$ Thanks for this, but it still doesn't solve the problem completely. I would like to add random colors directly as I create the new objects for better viewport readability like in 2.8. With this addon, I would have to create different materials for various objects and for addon to work which is too much of work for large scenes. Thanks for the help though. $\endgroup$ – AshKB Aug 10 at 15:34
  • $\begingroup$ That is the limitation for Cycles in <=2.79, the viewport color is tied to a material. I don't think there is a workaround for that. $\endgroup$ – rjg Aug 10 at 16:01

There a couple addons for it. I use random_material_viewport_colors. But as far i know, these addons do random material color, not object. So you need to create material for every object you need to be random colored.

  • $\begingroup$ Not true, you can set the viewport color in 2.79b as well. $\endgroup$ – rjg Aug 10 at 10:10
  • $\begingroup$ Yes, but i mean addons can do random colors only for materials. But i can be wrong. $\endgroup$ – Magnus Aug 10 at 10:21

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.