2
$\begingroup$

Can one get (in python) transform properties (location, rotation ect.) of the objects created by the array modifier? (while the array modifier is active, without applying it)

I need to be able to snap some other object to one of the array duplicates

thanx

$\endgroup$
  • $\begingroup$ Doing that implies recoding part of the modifier in Python (eventually taking into account other modifiers in the stack)... so if your situation has some specific parameters for the modifiers you should explain it in the question (as a generic recoding of the array is not a so simple thing). $\endgroup$ – lemon Apr 24 '18 at 10:20
  • $\begingroup$ Whatever geometry array modifier creates it's not exposed to API as objects as far as I can tell. But you are able to snap to array-created geometry through vertex / edge / face mode as with the original mesh. $\endgroup$ – kheetor Apr 24 '18 at 11:21
  • $\begingroup$ An exposed api would be nice... as the api is probably not exposed (why?), I guess I will have to find some other workarround. Ijust need the locations and rotations of the objects. snap is not the right term to use. I need to get other objects to the locations of the array objects programmetically. any link to learn about that array recording thing? $\endgroup$ – gnotev Apr 24 '18 at 12:01
  • 1
    $\begingroup$ @gnotev, technically speaking, array modifier does not create a sequence of separated objects. It creates additional mesh parts which are inside the same original object. So from the array modifier result, there is no simple way to retrieve these mesh parts. The only way is to recalculate all from the original object and the array parameters (but as I said above, you need to provide more information to see if the calculation is possible or not) $\endgroup$ – lemon Apr 24 '18 at 12:35
  • $\begingroup$ I'd say this is quite do-able. Being a modifier, it does create the arrays as one mesh, but in doing so is calculating the local coords of each copy, Suggest grabbing the c source code and emulating in python. As stated previously would only need to create an array of matrices each having the transform of array instance. $\endgroup$ – batFINGER Apr 24 '18 at 13:21
0
$\begingroup$

Using modifier array, e.g.:

def array(self, obj):
    mod = bpy.data.objects[obj.name].modifiers.new(name='array', type='ARRAY')
    mod.count = 10
    mod.relative_offset_displace[0] = 2.5

position and rotation can be calculated from the formula, e.g. 5th element in array would have x = 5 * mod.relative_offset_displace[0], so if original is [0,0,0] then 5th will be [6.25,0,0].

$\endgroup$
  • $\begingroup$ mod = obj.modifiers.new(...) Related $\endgroup$ – batFINGER Nov 3 '18 at 9:26

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.