object rotation

Hi I have problem and mayby python script will be solution

Is there any metod to get object rotation and set it to another object and slow down this rotation to 1/2

Yes you can by using pydrivers. Some documentation links:
http://wiki.blender.org/index.php/Dev:Source/Blender/2.42/PyDrivers

and a tutorial (for a different problem but using and explaining pydrivers)

http://www.opendimension.org/blender_en/rolling_along_path.php

Yes you can by using pydrivers. Some documentation links:
http://wiki.blender.org/index.php/Dev:Source/Blender/2.42/PyDrivers

and a tutorial (for a different problem but using and explaining pydrivers)

http://www.opendimension.org/blender_en/rolling_along_path.php

sorry for the multiple posts, either my line is flaky or blenderartists is slow …

Yes you can by using pydrivers. Some documentation links:
http://wiki.blender.org/index.php/Dev:Source/Blender/2.42/PyDrivers

and a tutorial (for a different problem but using and explaining pydrivers)

http://www.opendimension.org/blender_en/rolling_along_path.php

thanks I will try

To me, the rotation is a static parameter… Perhaps you’re speaking about the rate or speed of rotation?? :eek:

speed of rotation of course

I tryed but without any ideas. When I type anything even b.Ipo.Get there is error , not valid expresion

How should looks like my python expresion, I want to rotate second cube 2x faster than first and second must depends from first.Its very important to me
Thank

Ok… let’s try to figure out what is needed to do this: (1) info for rotation of object_1; (2) re-work this info so that it represents more speedy rotation (in our case factor = 2.0); (3) assign the re-worked info with object_2 in such a way that two objects look rotating simultaneously. This will result in two object rotating and the second object will rotate twice as fast as the first one, ok?

For (1) - the info can be extraxted from object_1 rotation IPOs… This will result in a list of points (value of rotation and time since the beiginning of animation). Under (2) - two approaches are possible - (a) use the same values but re-distribute them within a period of time = 1/2 of the original; or (b) use the same time data but multiply the rotation values by 2.0… At stage (3) - the re-calculated values should be assigned to rotation IPOs of object_2 :slight_smile:

I guess, you will wish to tey to implement this. :wink:

I can also help you with implementation but during the weekend…

Regards,

As a solution on the issue, pls consider the following script I made today:

from Blender import *
import bpy
import math
from Blender.Scene import Render

################################################################
#                                                              #
#  Script to make rotation of an object (second object) twice  #
#     as fast as rotation of another object (first object)     #
#                                                              #
#   * * *  This script shows the concept of the above  * * *   #
#                                                              #
################################################################

def Accel_2_times():
    stObjectName_1 = "Base"      # Use your names of objects...
    stObjectName_2 = "Cube.019"  # Use your names of objects...
    d_Ipo_1 = GetIpoInfo(stObjectName_1)
    if not Check_RotIPOs_avail(d_Ipo_1):
        return
    lst_RX,lst_RY,lst_RZ = Recalc_2_times(d_Ipo_1)
    SetRotIPOs_2(stObjectName_2,lst_RX,lst_RY,lst_RZ)
    Reflect_changes(stObjectName_2)
    Window.RedrawAll()
    return

#######################################

def GetIpoInfo(st):
    ob = Object.Get(st)
    anipo = ob.getIpo()
    d = {}
    for cu in anipo:
        lst = GetBezierPoints_All(cu)
        d[cu.name] = lst
    return d

def GetBezierPoints_All(cu):
    bp = cu.bezierPoints
    n = len(bp)
    lst = []
    for i in range(n):
        lst.append(bp[i])
    return lst

def Check_RotIPOs_avail(d):
    keys = d.keys()
    flag = True
    flag = flag and ("RotX" in keys)
    flag = flag and ("RotY" in keys)
    flag = flag and ("RotZ" in keys)
    n = len(d["RotX"])
    flag = flag and (len(d["RotY"]) == n)
    flag = flag and (len(d["RotZ"]) == n)  # RotX,RotY and RotZ lists should exist and have the same number of elements
    return flag
    
def Recalc_2_times(d):
    lst_RX,lst_RY,lst_RZ = [],[],[]
    n = len(d["RotX"])
    for i in range(n):
        val_X = d["RotX"][i].pt  # values from BezierTriple
        val_Y = d["RotY"][i].pt
        val_Z = d["RotZ"][i].pt
        val_X[1] = val_X[1]*2
        val_Y[1] = val_Y[1]*2
        val_Z[1] = val_Z[1]*2
        lst_RX.append(val_X)
        lst_RY.append(val_Y)
        lst_RZ.append(val_Z)
    return lst_RX,lst_RY,lst_RZ

def SetRotIPOs_2(st,lst_RX,lst_RY,lst_RZ):
    # Proc deals ONLY with rotation IpoCureves...
    ob = Object.Get(st)
    anipo = ob.getIpo()
    if (anipo <> None):  # if there is ALREADY an IPO of Object_2
#        I suppose that as soon as IPO exists => all rotation IpoCurevs exists in anipo.curves too!
        anipo[Ipo.OB_ROTX] = None
        anipo[Ipo.OB_ROTY] = None
        anipo[Ipo.OB_ROTZ] = None
    else:  # if Object_2 still has no IPO......
        anipo = Ipo.New("Object","oi_Object_2")
    anipo.addCurve("RotX")
    anipo.addCurve("RotY")
    anipo.addCurve("RotZ")
    n = len(lst_RX)
    cu = anipo.getCurve("RotX")
    for i in range(n):
        cu.append((lst_RX[i][0],lst_RX[i][1]))
    cu = anipo.getCurve("RotY")
    for i in range(n):
        cu.append((lst_RY[i][0],lst_RY[i][1]))
    cu = anipo.getCurve("RotZ")
    for i in range(n):
        cu.append((lst_RZ[i][0],lst_RZ[i][1]))
    ob.setIpo(anipo)
    return

def Reflect_changes(st):
    # In our case these refer to rotation of second object....
    sce = Scene.GetCurrent()
    context = sce.getRenderingContext()
    ob = Object.Get(st)
    anipo = ob.getIpo()
    curr_frame = context.currentFrame()
    # At this stage object's IPO should have some valid rotation IPOs
    RX = anipo.getCurve("RotX").__getitem__(curr_frame)
    RY = anipo.getCurve("RotY").__getitem__(curr_frame)
    RZ = anipo.getCurve("RotZ").__getitem__(curr_frame)
    ob.setEuler(math.radians(10*RX),math.radians(10*RY),math.radians(10*RZ))
            
#######################################

Accel_2_times()


It is fully working, just anticipating some “normal” circumstances during the process with the ONLY idea to save development time for NOT-implementing some theoretically necessary checks right now :wink: I used the method to increase values of rotation angles at the same keyframes --> this is a more clear approach I think…

Should interpolation mode of your IPO-curves is LINEAR => you will get exactly twice as fast rotation… BUT in case interpolation mode is BEZIER (which is the default) you will obtain twice as fast rotation ONLY at your key frames and NOT during the whole animation, ok?

thanks Abidos I’m very grateful but how to use it?, I have it in text editor but in constraint window there isn’t any script
I also try in skriptlink panel and here it is but not working

You have it in your text window and this is ok… Just press ALT+P to start it :slight_smile:
Before that do change names of your objects --> see rows 1 and 2 in Accel_2_times() procedure as mentioned there :wink:

I change names and it still not work mayby I did something wrong?
Check blend file

untitled_6.blend (66 KB)

I have looked at your file… There is a problem that your object_1 has only RotX IPO-curve and Check_RotIPOs_avail(d_Ipo_1) @ row 17 returns “False” and stops script there… :cool: In the script, it is anticipated that ALL rotation curves are available - RotX, RotY and RotZ… This script is NOT that flexible to “sense” which of those are avail and work ONLY with the avail curves of object_1… The function Check_RotIPOs_avail also checks if those three rotation curves have the same number of key-points. It doesnt check if key-points are at same time (frame) though… so it is NOT perfect… Sooooooo try with ALL rotation curves available OR modify the script… The latter would be more difficult :wink:

Also… in my previous post, my point was that the user changes names of object_1 and object_2 @ rows 16-17 within the script and NOT their names in 3D window… This is more handy, I think :slight_smile:

Here is a short animation I produced based on your file with adding RotY and RotZ ipo-curves ALL with “0” values so that there is a rotation only on X as at your original.

Regards,

thanks now it works, later I try to modify script for one axis rotation

ps.
I would like to learn python, do You have any favourite web site with tutorials ??

OK, this is nice! :slight_smile:

For working with Python in Blender I use the Blender Python API Reference and help files in PythonWin Editor… My method is reading help file to learn what and how one may use, then try to build a simple example of application, then - when I know what may be expected from certain code - incorporate it into a bigger project… There may be some iteration reading-testing-reading-testing-reading-testing though :wink: I think, previous experience in programming will be of help… Math knowledge - too!!! Then - it is a matter to code your ideas and fantasy :spin:

A good start of your Python programming in Blender may be modifying the function Check_RotIPOs_avail to check also if keypoints in ALL rotation curves are ALSO at the same place/time…

http://docs.python.org/tutorial/