Recursive duplicator [Python] – Blender

Recursive duplicator [Python] – Blender 1 - steamclue.com
Recursive duplicator [Python] – Blender 1 - steamclue.com

A very simple duplicator that recursively duplicates objects, scales and moves them in local axes.
 
 

Introduction

  • A very simple duplicator that recursively duplicates objects, scales and moves them in local axes.
  • The transformation can be applied to any object. It will move and scale on the y-axis.
  • Parameters can be used to set scale and offset on other axes.
  • Script works on local axes!

 
Recursive duplicator [Python] - Blender - Introduction - 58EA7F046
 
 
Recursive duplicator [Python] - Blender - Introduction - CE55AAA01
 
 
 

Python code

import bpy
import mathutils

duplicates = 1

scale_on_x = 1
scale_on_y = 1.045
scale_on_z = 1

move_on_x = 0
move_on_y = 0
move_on_z = -0.036


def simple_duplicate(dobject, limit, actual):
 copy_of_dobject = dobject.copy()
 bpy.context.collection.objects.link(copy_of_dobject)
 bpy.context.view_layer.objects.active = copy_of_dobject
 inv = copy_of_dobject.matrix_world.copy()
 inv.invert()

 # move
 copy_of_dobject.location += mathutils.Vector(
 (move_on_x, move_on_y, move_on_z)
 ) @ inv
 
 copy_of_dobject.scale = (
 copy_of_dobject.scale[0] * scale_on_x, 
 copy_of_dobject.scale[1] * scale_on_y, 
 copy_of_dobject.scale[2] * scale_on_z
 )
 
 actual += 1 
 if actual <= limit:
 print("call") 
 simple_duplicate(copy_of_dobject, limit, actual)

# execute
simple_duplicate(bpy.context.active_object, duplicates, 1)

 
 
Recursive duplicator [Python] - Blender - Python code - 7C6FF234B
 
 
Recursive duplicator [Python] - Blender - Python code - 6438FB81E
 
 
 

Conclusion

 _ _ _ _ 
 | || |__ _ _ __ _ __ _ _ __ ___ __| (_)_ _ __ _ 
 | __ / _` | '_ \ '_ \ || | / _/ _ \/ _` | | ' \/ _` |
 |_||_\__,_| .__/ .__/\_, | \__\___/\__,_|_|_||_\__, |
 |_| |_| |__/ |___/ 

 
 

Written by DevDave

 
 
I hope you enjoy the Recursive duplicator [Python] – Blender guide. This is all for now! If you have something to add to this guide or forget to add some information, please let us know via comment! We check each comment manually!
 


Be the first to comment

Leave a Reply

Your email address will not be published.


*