0
$\begingroup$

So I want to animate multiple "cables" (witch are curves), i want to animate the bevel start (or end) and add a random offset to this value. I could put some keyframes and offset them manually but i got a lot of curves.

  1. Is there is a more efficient way to do it ?
  2. Is it possible ?
  3. Is it possible to create drivers for an object with pyton ?

I've made a blend file with my progress so far : curves+python blend file

Thanks for any help

Edit : I could create multiple cable object and add to each object a curve modifier (how to link it to one object ?)and offset them randomly (I know how to do it), and animate them.

$\endgroup$
1
$\begingroup$

Am using "Commotion Add-on" for random offset effects. That should be the best Add-on to handle that

$\endgroup$
  • $\begingroup$ Thanks ! I’ll give it a try. $\endgroup$ – Ben Hub May 14 '19 at 6:19
0
$\begingroup$

I updated my script so it also add the random offset for the animation

import bpy
import random

i = 0
depth = 0.1
resolution = 8


def blenderNumber(number):
    if number == 0:
        return ("")

    else:
        if number < 10:
            return ("00{0}".format(number))
        elif number < 100:
            return ("0{0}".format(number))
        elif number <1000:
            return (number)


while i < 50:
    if i == 0:
        frameRandom = 50

        bpy.data.curves["Mesh"].fill_mode = "FULL"
        bpy.data.curves["Mesh"].bevel_depth = depth
        bpy.data.curves["Mesh"].bevel_resolution = resolution

        bpy.data.curves["Mesh"].bevel_factor_start = 1
        bpy.data.curves["Mesh"].keyframe_insert(data_path = "bevel_factor_start", frame = 0)

        frameRandom += random.randint(-20,20)
        bpy.data.curves["Mesh"].bevel_factor_start = 0
        bpy.data.curves["Mesh"].keyframe_insert(data_path = "bevel_factor_start", frame = frameRandom)



    else:
        frameRandom = 30

        tempMeshName = '%(Mname)s.%(Mnumber)s' % {'Mname': "Mesh", "Mnumber": blenderNumber(i)}
        bpy.data.curves[tempMeshName].fill_mode = "FULL"
        bpy.data.curves[tempMeshName].bevel_depth = depth
        bpy.data.curves[tempMeshName].bevel_resolution= resolution

        bpy.data.curves[tempMeshName].bevel_factor_start = 1
        bpy.data.curves[tempMeshName].keyframe_insert(data_path = "bevel_factor_start", frame = 0)

        frameRandom += random.randint(-20,20)
        bpy.data.curves[tempMeshName].bevel_factor_start = 0
        bpy.data.curves[tempMeshName].keyframe_insert(data_path = "bevel_factor_start", frame = frameRandom)
        bpy.data.curves[tempMeshName].keyframe_delete

    i += 1
$\endgroup$

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.