Animation from Blender into OsciStudio


#1

Hellos,

This is my first ever attempt to patch a simple python script for Blender 2.9 that could import a series of of svg files that conform an animation. Perhaps of use to someone else here.

I want to be able to enable and disable their visibility so to simulate an animation, this is to be sent to a software called OsciStudio that generates sound from the objects on the viewport.

What I have tried is this:

##################
import bpy
import glob
import os  

# path to your folder

importDir = "/Volumes/250GB/16mm/rotoscope/stillsprecol/select/" 
print("Importing all SVG from this directory", importDir)

os.chdir(importDir)

for files in glob.glob("*.svg"):
    print( files, "... imported!" )
    bpy.ops.import_curve.svg(filepath=files)
    bpy.ops.object.select_all(action='SELECT')

for i, obj in enumerate(bpy.context.selected_objects, 1):
    bpy.context.view_layer.objects.active = obj
    obj.name = "Curve" + str(i)

    obj.location = (3.0, 4.0, 10.0)
    obj.keyframe_insert(data_path="location", frame=1)

Importing works fine, i get all the files layered and selected but have no idea on how to add a keyframe to each layer, progressively and separated by 10 frames.

I’m using blender 2.9 under OS X

TIA for any, really any, help


#2

Looks like you got some good help over on stackexchange? Good folks over there for blender coding help…


#3

definetively yes. Still some more can be done to leverage the complexity of curves before sending them to Oscistudio… i have tried with

``bpy.ops.curve.decimate( *ratio=1.0* )

But I see no changes on the curve and, cause of the many layers generated OsciStudio turns red… like saturated.

buu


#4

Maybe try a lower value (i.e. 0.5 or something) for the ratio. I know there’s a built-in blender add-on called simplify curves. While this requires manual intervention (something you’re trying to avoid, I understand,) you might get some insight on how that add-on works by looking at the python code…


#5

you can import a series of SVGs as animation directly into oscistudio, without blender at all.

  1. open oscistudio
  2. select all your files in explorer/finder
  3. drag them onto the top of a group in oscistudio and hold ctrl key
  4. release the mouse button :slight_smile:

you should now be able to use the “time” slider of that group to go through the different files


#6

you both thanks for the replies.

I have tried loading directly into OsciStudio, get the layers but see no change or effect on sliding the “time” slider.
No matter I load the .svg’s while holding cmd o ctrl (on a mac).

I have tried creating a sequence through the Timeline and using a very low frequency I get the effect of onion skin… so getting closer to a short loop animation of 10 layers. But not yet there.

Will see if I can get a better grasp of .svg files as frames for an animation using the VAMP Blender plugin and trying again the export animation feature.

Tx!