Widget array

So I try to create duplication with the widget. To have control with on count of copies from in distance of first to last copy. I imagine that this feature can be done with an array modifier. So I create this example. What I need to do is to add a driver to an array modifier via python to “constant offset” value.

2 Likes

I found some code here https://blender.stackexchange.com/questions/132160/how-to-add-driver-to-modifier-simpledeform-angle-by-scipt-python-in-blender-2-8 for adding drivers to “Simply deformation”, and I tried to translate it to “array”. But without success. Keep digging

import bpy

ob = bpy.context.object
array = ob.modifiers.new(name="array",type ='ARRAY')
bpy.context.object.modifiers["array"].use_constant_offset = True

Xcurve = array.driver_add('relative_offset_displace[0]')
Xdriver = Xcurve.driver
Xdriver.expression = "-(nat-wid)/(count-1)"

print('________')