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$
2
  • $\begingroup$ is it possible to use one text object? if no should they always be linked? $\endgroup$
    – Chebhou
    Feb 17, 2015 at 22:29
  • $\begingroup$ @Chebhou They should always be linked, as in changes to one affect all the others. $\endgroup$
    – J Sargent
    Feb 18, 2015 at 13:57

2 Answers 2

15
$\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.

$\endgroup$
10
  • $\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$
    – J Sargent
    Feb 17, 2015 at 22:40
  • 1
    $\begingroup$ @NoviceInDisguise Thanks, I will check this tomorrow. $\endgroup$
    – stacker
    Feb 17, 2015 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$
    – J Sargent
    Feb 18, 2015 at 14:00
  • $\begingroup$ @NoviceInDisguise The 2nd version of the script allows you to select from already loaded fonts. $\endgroup$
    – stacker
    Feb 19, 2015 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, 2015 at 12:05
0
$\begingroup$

Does not work on macos 12.4. Blender version used 2.8. Probably the pyton version. I need to generate 10000 objects 1, 2, 3 .... 100000. That is with a difference of +1. Could you help?

$\endgroup$
1
  • 2
    $\begingroup$ If you have a new question, please ask it by clicking the Ask Question button. Include a link to this question if it helps provide context. - From Review $\endgroup$ Jun 16, 2022 at 12:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .