2
$\begingroup$

quick question: when i use an empty as an object offset in the array modifier and i rotate for example an array of cubes with it around the y-axis i get a circular arrangement like this: my problem is it possible to get the empty rotation on the objects themselves like this, so that the objects stay on the z-axis? the rotation has to increase with each new object (i.e. 10 / 20 / 30 degrees etc.) my goal

thank you in advance!

$\endgroup$

2 Answers 2

2
$\begingroup$

I dont think you can do this with the array modifier or a different modifier. So I made this code:

import bpy 
import math

Count = 10
distance  = [0, 2, 0]

rotationX = 10                              # in degrees
radiansX = rotationX *(math.pi / 180)       # in radians

rotationY = 0
radiansY = rotationY *(math.pi / 180)

rotationZ = 0
radiansZ = rotationZ *(math.pi / 180)

startRotationX = 0
startRotationY = 0
startRotationZ = 0

for x in range (0, Count - 1):
    bpy.ops.object.duplicate_move(OBJECT_OT_duplicate={"linked":False, "mode":'TRANSLATION'}, TRANSFORM_OT_translate={"value":(distance[0], distance[1], distance[2]), "constraint_axis":(False, False, False), "constraint_orientation":'GLOBAL', "mirror":False, "proportional":'DISABLED', "proportional_edit_falloff":'SMOOTH', "proportional_size":1, "snap":False, "snap_target":'CLOSEST', "snap_point":(0, 0, 0), "snap_align":False, "snap_normal":(0, 0, 0), "gpencil_strokes":False, "texture_space":False, "remove_on_cancel":False, "release_confirm":False})

    if x == 0:
        startRotationX = bpy.context.object.rotation_euler[0] 
        startRotationY = bpy.context.object.rotation_euler[1] 
        startRotationZ = bpy.context.object.rotation_euler[2] 

    bpy.context.object.rotation_euler[0] = startRotationX + (radiansX * (x + 1))
    bpy.context.object.rotation_euler[1] = startRotationY + (radiansY * (x + 1))
    bpy.context.object.rotation_euler[2] = startRotationZ + (radiansZ * (x + 1))

I hope this works!

$\endgroup$
2
  • $\begingroup$ hey, first of all thanks for your afford! i have pasted your code in the console and the only thing i get is an array of 10. but there is no rotation at all. am i doing something wrong? i am using the console for the first time. $\endgroup$ Commented Nov 21, 2016 at 14:41
  • $\begingroup$ for me it is working. Maybe you need to paste it in the text editor? $\endgroup$
    – float
    Commented Nov 21, 2016 at 14:42
1
$\begingroup$

enter image description here

I would recommend Drivers for this. It really depends on what you are doing, but if turns into anything related to animation, this seems logical.

The disclaimer is that it won't work with the array modifier, however duplication via something like Ctrl+D also copies the driver so that part stays dynamic.

First steps are to create both a cube and an empty at the 0,0,0 origin.

To create the driver, 1st select the Cube Object, then turn on your properties panel N, and Right-Click on the X rotation field >> Then Add Single Driver.

Go to the Graph Editor Screen, and at the bottom menu change F-Curve to Drivers.

N to bring up the right side panel if it's not up already.

At the left side of the Graph Editor, be sure to select the X Euler Rotation Entry.

Scroll down to the bottom of the panel on your right and there should be a variable called var already, make sure that its type is set to distance, I believe that by default it gets set to Transform Channel.

Then set Ob/Bone 1: Empty

Then set Ob/Bone 2: Cube

Up above the variable list is an Expression field labeled Expr:, go ahead and set this field to the following:

var*((pi*0.5)*.1)/-2.00000

And hit enter.

You can now close the graph editor, and keyframe &/OR duplicate the cube around, and it will rotate respective to its distance from the Empty's location.

$\endgroup$

You must log in to answer this question.

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