r/blenderpython • u/dphamiltonbradford • Oct 12 '18
r/blenderpython • u/seetheglobey • Oct 05 '18
Blender Python script to set up animation in which random text appears on screen
emalis.comr/blenderpython • u/OysterSauce • Jan 10 '18
Anyone in Southern California? I have some paid blender extension work for you!!
Apologies if this post isn't allowed here!
I have a project that just got funded, based in San Diego, and I need someone with experience in Blender & Python (Blender-thon?) for some part time help. Would be paid (pay based on experience/skill), and would be very flexible on hours, etc. Would prefer in the southern California region as periodic a face-to-face meetings would be nice, but you wouldn't be required to work on-site. Please reach out if this interests you!
r/blenderpython • u/cryptobillionaire • Oct 19 '17
Need help running a python script in batch mode [crosspost from /r/blender]
r/blenderpython • u/PhilMeCurryErryday • Sep 11 '17
moving vertices over time in python
hi there,
im new to bpy and i just wanted to mess around and try things. right now i want to manipulate vertices of a cube over time. my goal is to make a wabbling cube with the sin function. the example below is a reduced example where i just want to manipulate the vertices.
the thing im struggeling with is, i don't know how to make those changes visible each time i changed the vertex coordinates. When i run the script blender kinda freezes for 5 second and then i see the end result. i want to see the transition.
import bpy
import time
from math import sin
cube = bpy.data.objects['Cube']
start_second = time.time()
end_second = start_second + 10
while start_second < end_second:
t = time.time()
for vertex in cube.data.vertices:
vertex.co.x = sin(t/10.0)*2.0
start = time.time()so how is that done right :)
r/blenderpython • u/antirabbit • Jul 18 '17
Why is mesh.from_pydata() resulting in segmentation faults?
I am trying to randomly generate meshes with slight modifications computed before the objects are created. Below is some code that creates the mesh, but right now it crashes unless the number of vertices is small.
I have vertex and face data loaded from a cube that was subdivided many times, with a total of 26138 vertices and slightly fewer faces.
I am loading the object in a script, and whenever I try to load it with mesh.from_pydata, I get a segmentation fault (core dumped) error.
mymesh = bpy.data.meshes.new(mesh_name)
myobject = bpy.data.objects.new(mesh_name, mymesh)
bpy.context.scene.objects.link(myobject)
print('loading from pydata...')
mymesh.from_pydata(vertices,[],faces)vertices is either a numpy array or a list object. I've tried both, and the segmentation fault occurs in both. faces is a standard list of tuples corresponding to vertex indices.
Here is the log from /tmp/blender.crash.txt
Blender 2.78 (sub 0), Commit date: 2017-02-24 14:33, Hash e92f2352830
bpy.context.space_data.bookmarks_active = 0 # Property
backtrace
./blender(BLI_system_backtrace+0x1d) [0x19aad1d] ./blender() [0x104e2e6] /lib/x86_64-linux-gnu/libc.so.6(+0x354b0) [0x7f720bccf4b0] ./blender() [0x19abc88] ./blender() [0x19ab12d] /lib/x86_64-linux-gnu/libpthread.so.0(+0x76ba) [0x7f720d2df6ba] /lib/x86_64-linux-gnu/libc.so.6(clone+0x6d) [0x7f720bda13dd]
r/blenderpython • u/coder86 • Dec 15 '16
GitHub - lowlevel86/blender-to-gnuplot: Export to gnuplot from blender 2.49b.
r/blenderpython • u/___Majestic_Moose___ • Sep 07 '16
BGE ProcGen
So, I've been working on procedural generation for my game (which - once finished - will be ported to unreal), having the code do most of the heavy lifting during runtime.
I've been using a method of passing variables from the bge to a separately running instance of blender (using bpy) on my server. From these variables, it generates the appropriate objects, saves them in the server database, and sends the blender file to the client. This is proving to be quite taxing on the host computer and its internet connection, having to pathfind for hundreds of characters, validate client movements etc, AND generate meshes to be sent.
Due to this, I decided to move mesh generation to the client computers, but it's resulted in having to run blender simultaneously in the background. I tried compiling bpy as a to use in the standalone blender player, but importing it just crashes it all.
Now, I was wondering if (IIRC there was a project to work the bpy into the bge a while ago, but I lost track of it) there is any kind of implementation that would help me. I shall be eternally grateful to anyone able to guide me towards a solution.
EDIT: I've found this so shall be re-attempting to compile it. In the meantime, I would still be incredibly happy about any assistance offered. If I find a solution, I shall post it.
r/blenderpython • u/3DJourneyman • Apr 08 '16
Where should I start to develop addons for Blender?
I am interested in creating addons for Blender. However, I have no clue where to start. The main points I am interested in are:
IDE support: I do not know how to get the Blender API to work on Python-supported IDEs, like Eclipse or Visual Studio's Python Tools.
Learning resources: Video, websites, whatever is available is fine.
Thanks in advance.
r/blenderpython • u/Rclub • Feb 08 '16
error in communicating blender with arduino
I am new to blender and i want to communicate b/w arduino and python.first i wrote the code in Arduino it prints values like this
Serial.print("Val");
Serial.print(AN[0]);
Serial.print(",");
Serial.print(AN[1]);
Serial.print(",");
Serial.print(AN[2]);
Serial.println(); and it is working fine.. after that i went to blender and opened text editor and wrote python code as below import serial import bpy ser = serial.Serial(port='COM15',baudrate=9600, timeout=100)
accel=[None]*3
while 1:
line = ser.readline()
print(line)
ser.close after that i pressed atl+P but i am getting error like bpy.ops.text.run_script() Python script fail, look in the console for now... (my python code indentation is correct only) if i execute the same code(except import bpy) in the externall python it is working fine what might be the problem?
r/blenderpython • u/Trixworld • Jan 06 '16
How do I make Python Control an Changing Animation?
Hey Guys,
Alright, so I am working on a student project in blender. My company wants me to take files that look like this and turn them into animations of a person walking.
Now, please bear with me as I explain this. Alright, so what these lines of code do is tell an operator,which is a human in an assembly line, what to do. aka, when to turn, how much to turn, what to pick up, when to walk and how far etc. And, the only ones that I am going to use for my animation are the turns, and the walks. So I have highlighted those here.
Alright, so what this code actually means is... TIP = Turn and the number after that is how may degrees of a turn it should be OBS and UOBS are walks. OBS is a obstructed walk, and UOBS is a Unobstructed walk. (The reason that this matters is that the Obstructed walk takes more time because you have something you need to walk around).
So, what I am tasked with doing is taking these files, and directly inputting them into blenders python module, and according to what the file says the human operator should do, the model that I have will follow. The reason that i'm doing this is so that mistakes in the files can be easily found and eliminated.
Okay, so down to the actual question...
First off, thanks for reading this far! I appreciate it! My main problem is that I have is I don't know how to make blender ask for input or even how to put one in. Once I got that figured out what I was thinking of doing is setting a bunch of variables to mean something. Like, there could be a 'walk' variable and within that variable it could contain all the python code for one step of the animation, and that code could just be repeated for however many steps the file had. However, the problem with that Is that the animation wouldn't move across the room, he would just take a step in the air. So, I was thinking that I could multiply the amount of steps the animation is supposed to take by a certain number of blender units to make him move forward. I cannot see any problems with this... yet.
Thanks for any help! It is VERY much appreciated. Trixworld
r/blenderpython • u/Trixworld • Dec 13 '15
Asking for user input in using scripting
Hi,
I am fairly new to python (Have been using it for about a month now) and I am trying to create something in Blender that asks for a user input and then writes it out in a text mesh.
This is my code so far.
Once I hit run script then Blender immediately freezes and crashes. I am not sure what happened. When I was first testing things out I used This code and it worked fine.
Any help would really be appreciated!
r/blenderpython • u/corndogluver • Apr 24 '15
Hiring contrator for plant simulator
docs.google.comr/blenderpython • u/cgWanted • Feb 02 '15
Looking to hire blender/python person for contract.
We need a way of automatically generating images of cropland using a combination of Blender, pre-generated plant models, and Blender/Python scripting. We are looking for someone experienced with Blender and scripting to create a realistic ground/environmental model (the ground texture may be procedurally generated, but must be realistic); and a script that places pre-generated plant models in rows to simulate cropland. the script must also contain parameters controlling camera position, lighting conditions and sun position, and parameters such as plant spacing; allowing us to alter (and randomise) the scene that is generated. The scene must render in Blender, and be photorealistic.
Plant models are available using tools such as the Plant Factory. The deliverables are the realistic ground/environmental model; and the parametrised script to generate scenes.
r/blenderpython • u/MyNameIsBarryAllen • Jan 25 '15
Learning Python
Hello everybody! I'm learning python so i was wondering what kind of things could i do in Blender as a beginner at this language? I feel like exercising the use of python inside Blender could help me learn the language.
r/blenderpython • u/ClassFoo • Jan 19 '15
Completely disable editing of a scene object
My problem: I need to disable editing of an object (that I create from script). I know that there are options like: lock_rotation, lock_location, lock_scale, bpy.data.objects['name'].hide_select. But I want to completely deny user of interacting with object except that he can see it in 3dView. Object linked from another .blend file is great example of an 'disabled object' that I want to make. Any ideas?
r/blenderpython • u/sirrandalot • Jun 20 '14
Would anyone happen to know how to apply forces (using python) to rigid body objects? (In the integrated system, not the game engine)
I'm trying to apply forces to rigid body objects, but because my simulations are getting larger and larger, I would like to be able to bake them to disk. The integrated physics system is perfect for this but I can't figure out how to apply a force to each object on each frame. I have a script written out for calculating the force but I can't find out how to get that into the simulation. Any help would be great, thank you!
r/blenderpython • u/AntonioJBer • 11d ago
Python tools to rig and animate characters in Blender from a predicted skeleton (UniRig), open source
I've been writing Blender Python for a rigging pipeline and made it public. Sharing in case the approach is useful even if you don't use the whole thing.
The GIF is the result on one character: the body's skeleton and skin weights came out of this pipeline, and the animation was scripted in Blender.
The idea: every step is a script with a recorded input, so you can rerun it.
- A static GLB goes in, UniRig predicts the skeleton, and you review it in Blender and approve it (by hash) before the skin weights are inferred.
- Body animation from editable pose descriptions and an explicit bone map, baked into named clips and exported to GLB and .blend.
- Facial controls built from jaw landmarks and shape-key displacements.
- Retargeting between compatible rigs with an explicit bone map.
Python 3.11+, Blender for authoring. Original code MIT, some Blender modules GPL-3.0.
Repo: https://github.com/Octonove/octorig-studio
The Blender side has only been tested on synthetic rigs so far. If you've solved retargeting or facial controls differently in bpy, I'd like to compare.
r/blenderpython • u/abhi_physics90 • Feb 13 '26
Mesh Writer: Convert Unicode text into SVG, Geometry Curves and more
r/blenderpython • u/LalaCrowGhost • Dec 05 '25
Create Camera From View script fails because of incorrect context
My script fails at first execution in the Text Editor, which I dont mind, but when I run the script from the search menu while in 3D View, it creates a camera but throws an error and I cannot lock the transform or set the focal length with my 2 properties.
import bpy
from bpy.types import (Operator,)
import textwrap
from bpy.props import (BoolProperty,IntProperty,)
class OT_CreateCameraFromView(Operator):
bl_label = 'Create Camera From View'
bl_idname = 'my_tools.create_camera_from_view'
bl_description = textwrap.fill('Creates a camera from current view', 80)
bl_options = {'REGISTER', 'UNDO'}
focalLength : IntProperty (
name = "Focal Length",
description = "Delete UV channels after this number",
default = 50,
min = 1,
max = 300,
soft_min = 20,
soft_max = 120,
)
lockTransforms : BoolProperty (
name = "Lock Transforms",
description = "Locks location, rotation and scale",
default = False,
)
def execute(self, context):
initialActiveObject = bpy.context.active_object
camera = bpy.data.cameras.new(name = 'Camera')
camera_object = bpy.data.objects.new(camera.name, camera)
bpy.context.scene.collection.objects.link(camera_object)
bpy.data.scenes[bpy.context.scene.name].camera = bpy.context.scene.objects[camera.name]
for area in bpy.context.screen.areas:
if area.type == 'VIEW_3D':
for space in area.spaces:
if space.type == 'VIEW_3D':
space.lock_camera = True
bpy.ops.view3d.camera_to_view()
if self.lockTransforms:
bpy.context.view_layer.objects.active = bpy.data.objects[camera.name]
bpy.context.object.lock_location[0] = True
bpy.data.objects[camera.name].lens = self.focalLength
# Restore active object
if initialActiveObject != None:
bpy.context.view_layer.objects.active = bpy.data.objects[initialActiveObject.name]
return{'FINISHED'}
def register():
bpy.utils.register_class(OT_CreateCameraFromView)
def unregister():
bpy.utils.unregister_class(OT_CreateCameraFromView)
if __name__ == '__main__':
register()
bpy.ops.my_tools.create_camera_from_view('INVOKE_DEFAULT')r/blenderpython • u/Cheetahs_never_win • Oct 29 '25
os.listdir() appears to alter address

source_dir is a long directory, where there are folders consisting of dates.
When we invoke the os.listdir() command, that string representing a directory gets overwritten.
"2019" gets replaced with "x819" and 2019-12-09" gets replaced with "x819-12-09."
The EASY solution is to pull the Blend files directory upwards and circumvent directories with numbers.
But I'm hoping if somebody could shed some light on this unusual behavior, and what should be done to push through it.
Thanks!
r/blenderpython • u/Dylan_T_Rabbit • Oct 09 '25
Incorrect value from Scene Variable FloatProperty
SOLVED
After much fiddling, I found that accessing my Scene Variable as bpy.data.scenes["Scene"].inst_len works correctly. I'm confused as to the many ways to reference and access properties, but at least I know how to do it now.
I am developing an add-on/extension in Blender 4.5.3. It generates a pair of objects (Pad and Support) using an (already existing) reference object (in the test .blend: Instrument.)
I have set up two Scene Variables using bpy.props.FloatProperty - one for the position of the new objects (support_position in the code below) and one for the length of the reference object (inst_len.) I want to use inst_len to constrain the maximum value of support_position so I have written getter and setter methods for the two scene vars. I have also set up a basic sidebar panel with controls for these variables. When run, the inst_len control correctly displays the length of the reference object (or zero if there is no selected object,) however accessing the scene variable (with self["inst_len"] ) within its own getter method or that of support_position consistently returns the same value (3.629999876022339) no matter what the length of the reference object is. self["support_position"], on the other hand, returns the correct value. bpy.context.scene.inst_len and bpy.context.scene.support_position both return the correct value in my main() function and in the interactive console (although the erroneous value is present in both responses on the interactive console: e.g GET_LEN <bpy_struct, Scene("Scene") at 0x7f73e81a0420> 3.629999876022339 1.6502078771591187) but using these to reference the Scene Variable in the getters generates a recursion limit error.
Clearly, I am missing something or have made a basic error but I cannot work out what that might me. Any help would be appreciated. Thanks, Dylan
The .blend file and python script are available at Pastebin for files (until 15/10/2025)
bl_info = {
"name": "Instrument Supports",
"author": "DTRabbit",
"version": (0, 0, 1),
"blender": (4, 4, 1),
"location": "3D Viewport > Sidebar > Supports",
"description": "Make supports for musical instrument cases",
"category": "Object",
}
import bpy
from bpy.props import FloatProperty
# Globals - hopefully I can get rid of these at a later date
# 'constants' for vextor indexing
X = 0
Y = 1
Z = 2
# Instrument length for getter and setter functions
# this is set in the Poll() function and used in the getter
# and setter to make a dynamic max value
INSTRUMENT_LENGTH = 0
def select_object(object):
"""
select an object
"""
bpy.ops.object.select_all(action='DESELECT')
bpy.data.objects[object.name].select_set(True)
def delete_object(object):
"""
Delete an object
"""
select_object(object)
bpy.ops.object.delete()
def add_bool(owner, name, operation, object):
"""
Add a boolean modifier
owner: object boolean applies to
name: identifier for modifier
operation: boolean operation to apply
object: object used in operation
"""
boolean = owner.modifiers.new(name, 'BOOLEAN')
boolean.operation = operation
boolean.solver = 'MANIFOLD'
boolean.object = object
def apply_bool(owner, bool_name):
"""
Apply boolean bool_name to owner
"""
select_object(owner)
bpy.ops.object.modifier_apply(modifier=bool_name, use_selected_objects=True)
def add_and_apply_bool(owner, operation, object):
add_bool(owner, "temp_bool", operation, object)
apply_bool(owner, "temp_bool")
def add_block(block_name, block_size, block_location, block_scale):
"""
Add a block for further processes
"""
bpy.ops.mesh.primitive_cube_add(size=block_size, location=block_location, scale=block_scale)
block = bpy.context.object
block.name= block_name
return block
def apply_transformations(object, L = False, R = False, S = False):
select_object(object)
bpy.ops.object.transform_apply(location=L, rotation=R, scale=S)
def get_position(self):
global INSTRUMENT_LENGTH
print("GET_POS", self, self["support_position"], self["inst_len"])
return min(self["support_position"], self["inst_len"])
def set_position(self, value):
global INSTRUMENT_LENGTH
self["support_position"] = min(value, self["inst_len"])
def get_len(self):
global X
print("GET_LEN", self, self["inst_len"], bpy.context.selected_objects[0].dimensions[X] if len(bpy.context.selected_objects) == 1 else 0)
return bpy.context.selected_objects[0].dimensions[X] if len(bpy.context.selected_objects) == 1 else 0
def init_scene_vars():
bpy.types.Scene.support_position = FloatProperty(name="Position", description="Distance from end of instrument to centre of support", default=0.3, min=0, soft_max=3, get=get_position, set=set_position)
bpy.types.Scene.inst_len = FloatProperty(name="Len", default=0, get=get_len)
def del_scene_vars():
del bpy.types.Scene.support_position
del bpy.types.Scene.inst_len
def main(context):
global X, Y, Z
# the model to make a support and pad for
instrument = context.selected_objects[0]
# default parameters for pad and support
pad_thickness = 0.010 # 10mm
min_support_size = 0.010 #10mm
support_dim_X = 0.10 # 10cm
# Z coordinate of plane representing base of case
base_Z = 0
# distance from instrument axis to bottom of case
axis_to_base_Z = (instrument.dimensions[Z]/2) + pad_thickness + min_support_size - base_Z
# X location of end of instrument
ref_X = instrument.location[X]-(instrument.dimensions[X]/2)
# calculate X centre of support
relative_support_loc_X = context.scene.support_position
absolute_support_loc_X = ref_X + relative_support_loc_X
# location vector of the support
support_location = (absolute_support_loc_X, instrument.location[Y], instrument.location[Z]-axis_to_base_Z/2)
# construct a section of the instrument for building the pad and support
# a cube slightly wider than the support and scaled bigger than the max size
# in Y and Z
scaled_section = add_block("Scaled_Section", support_dim_X,
(absolute_support_loc_X, instrument.location[Y], instrument.location[Z]), (1.01, 10, 10))
# a boolean to cut instrument from block
add_and_apply_bool(scaled_section, 'INTERSECT', instrument)
# scale the section to allow pad thickness
pad_scale = 1+(pad_thickness/max(scaled_section.dimensions[Y], scaled_section.dimensions[Z]))
scaled_section.scale = (1, pad_scale, pad_scale)
apply_transformations(scaled_section, S = True)
# add support
# calculate size of support across instrument (= Y)
support_Y = scaled_section.dimensions[Y] + 2*(pad_thickness+min_support_size)
# scale vector for support from support_dim_X to required depth (Y) and height (Z)
support_scale = (1, support_Y/support_dim_X, axis_to_base_Z/support_dim_X)
# add a block
support = add_block("Support", support_dim_X, support_location, support_scale)
# cut the scaled section out
add_and_apply_bool(support, 'DIFFERENCE', scaled_section)
# add the pad
# a block the same as the support to start with
pad = add_block("Pad", support_dim_X, support_location, support_scale)
# a boolean to remove the instrument from the scaled section
# we won't need to apply this as the scaled section will be deleted
# when we're finished
add_bool(scaled_section, "Scale_Sec_Temp", 'DIFFERENCE', instrument)
# a boolean to cut the remaining part of the scaled section from the pad block
# we apply this one immediately
add_and_apply_bool(pad, 'INTERSECT', scaled_section)
# and finally, delete the scaled section
delete_object(scaled_section)
# make sure the original object is selected at the end
select_object(instrument)
class InstrumentSupports(bpy.types.Operator):
bl_idname = "instrument.supports"
bl_label = "Add Instrument Supports"
bl_description = "Creates supports and pads for musicl instrument cases"
bl_options = {"REGISTER"}
@classmethod
def poll(cls, context):
global X, INSTRUMENT_LENGTH
if len(context.selected_objects) == 1:
# INSTRUMENT_LENGTH = context.selected_objects[0].dimensions[X]
# print("SEL", INSTRUMENT_LENGTH)
return True
else:
# INSTRUMENT_LENGTH = 0
# print("DESEL", INSTRUMENT_LENGTH)
return False
def execute(self, context):
main(context)
return{'FINISHED'}
class VIEW_3D_PT_instrument_supports_panel(bpy.types.Panel):
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
bl_category = "Instrument Supports"
bl_label = "Instrument Supports"
def draw(self, context):
l = self.layout
l.label(text="Testing")
l.operator("instrument.supports", text="Inst Supp")
l.prop(context.scene, "support_position")
l.prop(context.scene, "inst_len")
classes = (InstrumentSupports, VIEW_3D_PT_instrument_supports_panel)
def register():
for c in classes:
bpy.utils.register_class(c)
init_scene_vars()
def unregister():
for c in classes:
bpy.utils.unregister_class(c)
del_scene_vars()
if __name__ == "__main__":
register()r/blenderpython • u/mixoadrian • May 14 '25
When 2 objecst with baked NLA animation tracks. Both named the same. Export glf work as intended from UI. But different behavior when try to do the same from script.



I have 2 objects animated, baked, pushsed down, moving.
accroding to blender manual, the nameNLA track must be same name to play together, so it is.
if i export through UI, export glb -> Mode choose NLA tracks, works as intended.
HOWEVER, i want to do this by script.
But Only one object is moving if i export from script.
export_nla_strips are set to true
but seems it only gets the active object's animation, or its just playing one animation of one obejct.
I can always manually use windwos UI to export, but this is annoying since i wanna automate this process.
Any ppl tried the same thing? is this a bug?