0
$\begingroup$
import bpy


def main(context):    
    bpy.ops.mesh.primitive_uv_sphere_add(enter_editmode=False, align='WORLD', location=(0, 0, 0), scale=(1, 1, 1))
    bpy.ops.object.modifier_add(type='ARRAY')
    bpy.context.object.modifiers["Array"].relative_offset_displace[0] = 10
    

    bpy.context.object.modifiers["Array"].count = 4
    bpy.ops.object.modifier_add(type='ARRAY')
    bpy.context.object.modifiers["Array.001"].relative_offset_displace[1] = 2
    bpy.context.object.modifiers["Array.001"].relative_offset_displace[0] = 0

    bpy.context.object.modifiers["Array.001"].count = 4

class SimpleOperator(bpy.types.Operator):
    """Tooltip"""
    bl_idname = "object.simple_operator"
    bl_label = "Simple Object Operator"


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

I want to add sphere and array modifier, error at line 10

$\endgroup$
2
  • 1
    $\begingroup$ Recommend mod = ob.modifiers.new(name, type) example blender.stackexchange.com/a/125098/15543 Then there is no need to guess at the modifiers name. (if using op will be last one added if successful. new_mod = ob.modifiers[-1]) $\endgroup$
    – batFINGER
    Dec 19, 2020 at 6:16
  • $\begingroup$ sry I don't understand, elaborate pls $\endgroup$
    – mohd mafaz
    Dec 19, 2020 at 6:29

0

You must log in to answer this question.

Browse other questions tagged .