CG: Blender – setting properties on multiple objects

Ran into the first hole in Blender’s feature set for non-technical users: there doesn’t appear to be an easy way to adjust the properties of multiple items at once.

I had just completed a tutorial about working with text and thought I’d update the hobbies graphic but this time using Blender.

I entered all the text easy enough but then it came time to set up the extrude, bevel depth and material assignments. It didn’t matter how many objects I selected, properties were only set on the active object (last item selected).

Screenshot taken around the time I decided to resort to scripting

To cut a long story short, I resorted to Python Script to get the job done. I’ve spent most of my CG time today learning how to use Python to drive Blender. Achieved my goal in the end and here’s the result.

Blended graphic showing competing hobbies

Update 24/10/2011: I wasn’t happy with that render so I had another go using the Cycles renderer.

Hobbies blended with cycles renderer

For the technically minded reader, here’s the script I devised. It’s based on the simple operator template and doesn’t do any error checking. you have to make sure you only have text curves selected.

import bpy

def main(context):
    for ob in context.selected_objects:
        ob.data.extrude = 0.08
        ob.data.bevel_depth = 0.025
        ob.data.bevel_resolution = 1
        ob.data.font = bpy.data.fonts['ErasITC-Bold']
        ob.data.materials.append(bpy.data.materials['matTextRed'])

class HobbyTextOperator(bpy.types.Operator):
    '''Script to set text properties for multiple objects'''
    bl_idname = "object.hobby_text_setup"
    bl_label = "Hobby Text Setup"

    @classmethod
    def poll(cls, context):
        return context.active_object is not None

    def execute(self, context):
        main(context)
        return {'FINISHED'}

def register():
    bpy.utils.register_class(HobbyTextOperator)

def unregister():
    bpy.utils.unregister_class(HobbyTextOperator)

if __name__ == "__main__":
    register()

    # test call
    bpy.ops.object.hobby_text_setup()
Advertisements
Comments
One Response to “CG: Blender – setting properties on multiple objects”
  1. jake says:

    Here’s a Blender 3D Tip: To work on a bunch of objects at a time, enable the “Copy Attributes” plugin that comes with Blender but isn’t on by default: open “User Preferences”, click “Addons”, then search for “copy attributes” to find the “3D View: Copy Attributes Menu” plugin. Enable the plugin then close preferences.

    To use:, in the 3D view, select one or more TARGET objects, then lastly select the SOURCE object. Press “Ctrl-C” on keyboard and see menu of every attribute type you can copy. Click one (e.g. scale) and you will see the scale of the source object will be applied to the previously selected objects.

    Here’s the manual entry http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/3D_interaction/Copy_Attributes_Menu

    See also:

    http://stackoverflow.com/questions/16625969/how-do-i-change-the-same-parameter-on-multiple-objects-efficiently-in-blender
    http://blenderartists.org/forum/showthread.php?24688-How-can-apply-a-material-to-multiple-objects-simultaneously

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: