9
$\begingroup$

The effect I am trying to achieve is an array that is fully editable in one instance, with Text labels incrementing in value, i.e. 1, 2, 3 etc. Is this possible? I know by nature it is not possible by using the Array modifier, but is there some workaround?

The sort of result I am going for is like this:

Incremental Array

What I was thinking is making a script to duplicate like with Alt+D and shove a count value into the Text element of the duplicated group.

Some things I am looking for/implementation suggestions:

  • Editable offset
  • Duplicates editable text element
  • Use a count variable to set the value of the text element
  • Make it expandable
  • Start from 1, go to at least 32 (non-limited is best)
  • Honesty as to the difficulty to create this feature
$\endgroup$
  • $\begingroup$ is it possible to use one text object? if no should they always be linked? $\endgroup$ – Chebhou Feb 17 '15 at 22:29
  • $\begingroup$ @Chebhou They should always be linked, as in changes to one affect all the others. $\endgroup$ – VRM Feb 18 '15 at 13:57
14
$\begingroup$

Here you go!

Keywords: Number Array Watch Dial

enter image description here

import bpy

from bpy.props import IntProperty,FloatProperty

class NumberArray(bpy.types.Operator):
    """Add a simple box mesh"""
    bl_idname = "mesh.primitive_number_array"
    bl_label = "Add Number Array"
    bl_options = {'REGISTER', 'UNDO'}

    start = IntProperty(name="Start",description="Start value",min=0, max=100,default=1 )
    count = IntProperty(name="Count",description="Number of items to create",min=1, max=100, default=1  )
    offset = FloatProperty(name="Offset",description="Distance",min=0.01, max=100.0, default=1.0 )

    def execute(self, context):
        x = 0.0
        pos = self.start
        end = self.count + self.start
        print(context)
        while pos < end:
            bpy.ops.object.text_add(view_align=False, enter_editmode=False, location=(x, 0, 0), layers=(True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False))
            ob=bpy.context.object
            ob.data.body = str(pos)
            x = x + self.offset
            pos = pos +1
        return {'FINISHED'}

def menu_func(self, context):
    self.layout.operator(NumberArray.bl_idname, icon='MESH_CUBE')

def register():
    bpy.utils.register_class(NumberArray)
    bpy.types.INFO_MT_mesh_add.append(menu_func)

def unregister():
    bpy.utils.unregister_class(NumberArray)
    bpy.types.INFO_MT_mesh_add.remove(menu_func)

if __name__ == "__main__":
    register()

Updated (works with 2.74):

enter image description here https://github.com/3dbug/blender

Run the script in Object Mode by Add / Curve / Create Dials and Scales.

| improve this answer | |
$\endgroup$
  • $\begingroup$ This is awesome!! You're the man! Can I edit one text object and have the changes reflected across them all (i.e. font changes)? $\endgroup$ – VRM Feb 17 '15 at 22:40
  • 1
    $\begingroup$ @NoviceInDisguise Thanks, I will check this tomorrow. $\endgroup$ – stacker Feb 17 '15 at 22:52
  • $\begingroup$ Changing the font doesn't appear to work, however I found a workaround. Select all, make the first active, and press L > Fonts. Works brilliantly! $\endgroup$ – VRM Feb 18 '15 at 14:00
  • $\begingroup$ @NoviceInDisguise The 2nd version of the script allows you to select from already loaded fonts. $\endgroup$ – stacker Feb 19 '15 at 7:28
  • $\begingroup$ @stacker I turned that into an addon in my collection, I added a few lines to get around the errors of no fonts existing. I also moved it to add curve as that is more accurate than a mesh object. $\endgroup$ – sambler Feb 19 '15 at 12:05

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.