Featured post

new redirect for blender.org bpy docs.

http://www.blender.org/api/blender_python_api_current/ As of 10/11 november 2015 we can now link to the current api docs and not be worr...

January 15, 2019

Blender bpy for 2.80+

With progress comes change.


Most of this info is found at 

https://en.blender.org/index.php/Dev:2.8/Source/LayersCollections/API-Changes
https://wiki.blender.org/wiki/Reference/Release_Notes/2.80/Python_API

my condensed version to self is:

linking objects to scene in 2.80

bpy.context.scene.objects.link
bpy.context.collection.objects.link


setting object to active in 2.80

bpy.context.scene.objects.active = ob
bpy.context.view_layer.objects.active = ob

object.to_mesh in 2.80

+ obj.to_mesh(bpy.context.depsgraph, apply_modifiers=bool, calc_undeformed=bool)


selecting objects

- object.select
+ object.select_get()
+ object.select_set()



December 02, 2018

Blender Python Recipes

I've been distracted for the past two years, but did manage to keep a small book
of recipes to keep the knowledge and experience out there in the public.

https://github.com/zeffii/BlenderPythonRecipes/wiki



May 13, 2016

The coordinates of Curve Control Points

See the docs for Curve Objects:
blender_python_api_current/bpy.types.Curve.html

Diego asks

HI... welcome back! :P sorry.. "fast" question... some ref in order to get the coordinates form curve control points???? thanks for any advice :D


take for example this Curve Object, which consists of three sub curve, 1 of which is a closed curve. Run this with the Curve Object in Object mode.


April 19, 2016

Getting Index (indices) of selected faces / polygons

One Way

# assuming the object is currently in Edit Mode.
import bpy
import bmesh

obj = bpy.context.edit_object
me = obj.data
bm = bmesh.from_edit_mesh(me)

for f in bm.faces:
    if f.select:
        print(f.index)

# Show the updates in the viewport
# and recalculate n-gon tessellation.
bmesh.update_edit_mesh(me, True)


Another Way

import bpy
import bmesh
from bmesh.types import BMFace

obj = bpy.context.edit_object
me = obj.data
bm = bmesh.from_edit_mesh(me)

for geom in bm.select_history:
    if isinstance(geom, BMFace):
        print(geom.index)

bmesh.update_edit_mesh(me, True)

Further Reading

I encourage you to know what the documentation says. blender.org/api/blender_python_api_current/bmesh.html?

April 15, 2016

Sverchok / Scripted node | 3d LSystem


..not novel

I haven't written anything on here for a while, this is the first opportunity since quite some time. It won't be in-depth. The following post assumes you've experimented with LSystems before.

Scripted Node MKI can read rules, (text files, one called RULES in the example) as well as the scripts that drive it's own internal node workings (called 3dlsystem.py).


The code for these things is available from github.

So what can it make?

Tragically I've not had much time to play with it, i'm hoping others might find it useful. As proof that It does work i'll include a few Rule sets.
with t_angle set to 0.02 it looks like grass in the wind..

Send me in your Rules files and i'll add them to this post.

November 12, 2015

new redirect for blender.org bpy docs.

http://www.blender.org/api/blender_python_api_current/

As of 10/11 november 2015 we can now link to the current api docs and not be worried about having to update old links. The following will always link to the latest docs.


http://www.blender.org/api/blender_python_api_current/

http://www.blender.org/api/blender_python_api_current/search.html?q=bmesh

http://www.blender.org/api/blender_python_api_current/mathutils.geometry.html


This means we don't have to specify the version anymore. If you really must link to older docs that's still possible. Mostly you probably don't care.

Thanks Ideasman42 and Kaito!

September 02, 2015

keyframing shape keys

This is totally a note to self :)