Instantly share code, notes, and snippets.

anonymous /
Created Mar 13, 2018

What would you like to do?
Simple Mover C4D Python Expression Tag
"""Name-US: Simple Mover
Description-US: Expression Tag that Moves and Object Over Time
Version History
v0.0.1 - Initial Version
Copyright (C) 2018 Maxon Computer Inc.
Written for
Written by Donovan Keith <>
import c4d
def GetValueAtTime(start, rate, time, offset=0.0):
"""Calculates PSR for rate at time. If vector is 0
for a given channel (XYZ, HPB), then start will be returned."""
value_at_time = start
if rate.x:
value_at_time.x = rate.x * time + offset
if rate.y:
value_at_time.y = rate.y * time + offset
if rate.z:
value_at_time.z = rate.z * time + offset
return value_at_time
def main():
obj = op.GetObject()
if obj is None:
# Get a direction/trajectory from the user
move = op[c4d.ID_USERDATA,1]
rotate = op[c4d.ID_USERDATA,2]
scale = op[c4d.ID_USERDATA,3]
# Get the time in seconds
time = doc.GetTime().Get()
# Position
start_pos = obj.GetRelPos()
new_pos = GetValueAtTime(start_pos, move, time)
# Scale
start_scale = obj.GetRelScale()
default_scale = 1.0 #Don't start from 0 scale.
new_scale = GetValueAtTime(start_scale, scale, time, offset=default_scale)
# Rotation
start_rot = obj.GetRelRot()
new_rot = GetValueAtTime(start_rot, rotate, time)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment