Just wondering if it’s possible to animate the curves “Mean Tilt” property with python.
I know it’s not keyframable but would it be possible to add X amount of degrees to all points in a curve per frame incrementally?
For example I have a rope bezier curve and I’d like to rotate it longitudely along the rope, I can do this by entering edit mode, selecting all curve points and Ctrl+T to rotate the mean tilt, but I really need to animate this.
Thanks so much! One thing I’m noticing is the script only animates 1 curve in the scene, is this due to it using the scene layout panel? If I changed it to the transform panel or somewhere else would that work individually on each curve? Thanks again
So I have 6 curves that I need spiraling (mean tilt) all at the same rate, not 100% sure on the rate yet as I’ll need to do a few test render sequences. If it’s easy enough to hard code an array of curve object names, I can fill out the curve object names in the script?
scn = bpy.context.scene
rot = scn.mytilt * scn.frame_current
for obj in bpy.data.objects:
if obj.type == 'CURVE':
cur = obj.data
points = cur.splines.active.bezier_points
tilts = [p.tilt for p in points]
tsum = sum(tilts)
if tsum > 0:
mean = tsum/len(points)
new_tilt = [t + rot - mean for t in tilts]
points.tilt = points.tilt #force curve to update :P
"""Creates a Panel in the scene context of the properties editor"""
bl_label = "Layout Demo"
bl_idname = "SCENE_PT_layout"
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "scene"
def poll(cls, context):
return context.active_object is not None and context.active_object.type == 'CURVE'
def draw(self, context):
layout = self.layout
scene = context.scene
row = layout.row()
bpy.types.Scene.mytilt = bpy.props.FloatProperty(name='Tilt', step=100.0, default=0, min=0, unit='ROTATION')
if __name__ == "__main__":
I changed the value in the panel to be used as a multiplier, i.e. tilt * currentFrame, so tilt=2 will change the mean tilt 2 degrees per frame. Things could get wonky if you use high numbers and/or long animations.