New tutorial series on Numpy for Blender

When I spoke at the Blender conference on creating an interactive cloth engine using python, I was surprised how many people knew nothing about Numpy. I’ve started to share some of the amazing things you can do with it inside of blender. Numpy lets you do things with python that can sometimes outperform comparable c code. Basic operations with Numpy are between 20 and 1000 times faster than typical python looping on big data. The code is also very clean and succinct.

I have four videos so far and I’m making more.
No commercials! No paying. Just sharing with the blender community as they’ve shared so much with me!

Thanks for this. I’ve used Numpy in some of my code, but felt I didn’t understand it enough to use it consistently, or know when using it would be beneficial.

Really cool of you doing this. Numpy is really the secret sauce you want if you’re doing Blender addons. It enables you to make so much more.

@Richcolburn, that is a very nice reference to have! thanks for it! :slight_smile:

thanks for sharing

would it be possible to make a video showing how to install Scy pi too!

and if possible open up a thread to give some scripts example using Numpy and Scipy

thanks
happy bl

@RickyBlender: Just install normal Python 3.5 with Scipy, then delete or rename Blenders Python folder.

will test that
but is python 3.5 the latest python ver or earlier then latest one !


this does not have numpy ?

got a specific link for 3.5 with numpy and scipy ?

thanks
happy bl

I made a demo of the modeling cloth tool if anyone is interested in it’s current features.

Posted a couple of new videos in the series https://www.youtube.com/watch?v=rE6XhUjPX_k&list=PLgJKmspCQMIivIdce4P_v4uqCh0f93tax

I’ve been working on updating my code to use numpy and foreach for better performance, but have hit a snag. Any idea why this simplified version of setting uv images with foreach_set doesn’t work?


# get the active object and its UV
ob = bpy.context.scene.objects.active
uv = ob.data.uv_textures.active

# use the first loaded image for example
img = bpy.data.images[0]

# apply the image with a slow for loop (works)
for data in uv.data:
    data.image = img

# apply the image with fast C loop (doesnt work)
uv.data.foreach_set('image', [img] * len(uv.data))

I’m not sure if there is a way to write an array full of objects to a blender collection. I don’t think I’ve ever gotten an array of images to work with foreach_set or foreach_get. I’ll look into it some more but if you find a solution let me know. So far I’ve only gotten it to work with bool, float, and int types. An image is an object with attributes. Maybe to use foreach_set for the image you just need an index array. Not sure. I couldn’t get it to work either.